Examples of Object


Examples of org.xwiki.rest.model.jaxb.Object

        for (ObjectSummary objectSummary : objects.getObjectSummaries()) {
            link = getFirstLinkByRelation(objectSummary, Relations.OBJECT);
            getMethod = executeGet(link.getHref());
            Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

            Object object = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

            checkLinks(objectSummary);

            for (Property property : object.getProperties()) {
                checkLinks(property);
            }
        }
    }
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

        final String TAG_VALUE = "TAG";

        Property property = new Property();
        property.setName("tags");
        property.setValue(TAG_VALUE);
        Object object = objectFactory.createObject();
        object.setClassName("XWiki.TagClass");
        object.getProperties().add(property);

        PostMethod postMethod =
            executePostXml(getUriBuilder(ObjectsResource.class).build(getWiki(), "Main", "WebHome").toString(), object,
                "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(postMethod), HttpStatus.SC_CREATED, postMethod.getStatusCode());

        object = (Object) unmarshaller.unmarshal(postMethod.getResponseBodyAsStream());

        Assert.assertEquals(TAG_VALUE, getProperty(object, "tags").getValue());

        GetMethod getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome", object.getClassName(),
                object.getNumber()).toString());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        object = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        Assert.assertEquals(TAG_VALUE, getProperty(object, "tags").getValue());
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

        final String TAG_VALUE = "TAG";

        Property property = new Property();
        property.setName("tags");
        property.setValue(TAG_VALUE);
        Object object = objectFactory.createObject();
        object.getProperties().add(property);

        PostMethod postMethod =
            executePostXml(getUriBuilder(ObjectsResource.class).build(getWiki(), "Main", "WebHome").toString(), object,
                "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(postMethod), HttpStatus.SC_BAD_REQUEST, postMethod.getStatusCode());
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

        final String TAG_VALUE = "TAG";

        Property property = new Property();
        property.setName("tags");
        property.setValue(TAG_VALUE);
        Object object = objectFactory.createObject();
        object.setClassName("XWiki.TagClass");
        object.getProperties().add(property);

        PostMethod postMethod =
            executePostXml(getUriBuilder(ObjectsResource.class).build(getWiki(), "Main", "WebHome").toString(), object);
        Assert.assertEquals(getHttpMethodInfo(postMethod), HttpStatus.SC_UNAUTHORIZED, postMethod.getStatusCode());
    }
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

    @Test
    public void testPUTObject() throws Exception
    {
        final String TAG_VALUE = UUID.randomUUID().toString();

        Object objectToBePut = getObject("XWiki.TagClass");

        GetMethod getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBePut.getClassName(), objectToBePut.getNumber()).toString());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        Object objectSummary = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
        getProperty(objectSummary, "tags").setValue(TAG_VALUE);

        PutMethod putMethod =
            executePutXml(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBePut.getClassName(), objectToBePut.getNumber()).toString(), objectSummary, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());

        Object updatedObjectSummary = (Object) unmarshaller.unmarshal(putMethod.getResponseBodyAsStream());

        Assert.assertEquals(TAG_VALUE, getProperty(updatedObjectSummary, "tags").getValue());
        Assert.assertEquals(objectSummary.getClassName(), updatedObjectSummary.getClassName());
        Assert.assertEquals(objectSummary.getNumber(), updatedObjectSummary.getNumber());
    }
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

    @Test
    public void testPUTObjectUnauthorized() throws Exception
    {
        final String TAG_VALUE = UUID.randomUUID().toString();

        Object objectToBePut = getObject("XWiki.TagClass");

        GetMethod getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBePut.getClassName(), objectToBePut.getNumber()).toString());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        Object object = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
        String originalTagValue = getProperty(object, "tags").getValue();
        getProperty(object, "tags").setValue(TAG_VALUE);

        PutMethod putMethod =
            executePutXml(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

    }

    @Test
    public void testDELETEObject() throws Exception
    {
        Object objectToBeDeleted = getObject("XWiki.TagClass");

        DeleteMethod deleteMethod =
            executeDelete(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBeDeleted.getClassName(), objectToBeDeleted.getNumber()).toString(), "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(deleteMethod), HttpStatus.SC_NO_CONTENT, deleteMethod.getStatusCode());

        GetMethod getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBeDeleted.getClassName(), objectToBeDeleted.getNumber()).toString());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_NOT_FOUND, getMethod.getStatusCode());
    }
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

    }

    @Test
    public void testDELETEObjectUnAuthorized() throws Exception
    {
        Object objectToBeDeleted = getObject("XWiki.TagClass");

        DeleteMethod deleteMethod =
            executeDelete(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBeDeleted.getClassName(), objectToBeDeleted.getNumber()).toString());
        Assert.assertEquals(getHttpMethodInfo(deleteMethod), HttpStatus.SC_UNAUTHORIZED, deleteMethod.getStatusCode());

        GetMethod getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBeDeleted.getClassName(), objectToBeDeleted.getNumber()).toString());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
    }
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

        Objects objects = (Objects) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        Assert.assertFalse(objects.getObjectSummaries().isEmpty());

        Object currentObject = null;

        for (ObjectSummary objectSummary : objects.getObjectSummaries()) {
            if (objectSummary.getClassName().equals("XWiki.TagClass")) {
                link = getFirstLinkByRelation(objectSummary, Relations.OBJECT);
                Assert.assertNotNull(link);
                getMethod = executeGet(link.getHref());
                Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

                currentObject = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
                break;
            }
        }

        Assert.assertNotNull(currentObject);

        Property tagsProperty = getProperty(currentObject, "tags");

        Assert.assertNotNull(tagsProperty);

        Link tagsPropertyLink = getFirstLinkByRelation(tagsProperty, Relations.SELF);

        Assert.assertNotNull(tagsPropertyLink);

        Property newTags = objectFactory.createProperty();
        newTags.setValue(TAG_VALUE);

        PutMethod putMethod = executePutXml(tagsPropertyLink.getHref(), newTags, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());

        getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                currentObject.getClassName(), currentObject.getNumber()).toString());
        Assert.assertEquals(HttpStatus.SC_OK, getMethod.getStatusCode());

        currentObject = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        tagsProperty = getProperty(currentObject, "tags");
View Full Code Here

Examples of org.xwiki.rest.model.jaxb.Object

        Objects objects = (Objects) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        Assert.assertFalse(objects.getObjectSummaries().isEmpty());

        Object currentObject = null;

        for (ObjectSummary objectSummary : objects.getObjectSummaries()) {
            if (objectSummary.getClassName().equals("XWiki.TagClass")) {
                link = getFirstLinkByRelation(objectSummary, Relations.OBJECT);
                Assert.assertNotNull(link);
                getMethod = executeGet(link.getHref());
                Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

                currentObject = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
                break;
            }
        }

        Assert.assertNotNull(currentObject);

        Property tagsProperty = getProperty(currentObject, "tags");

        Assert.assertNotNull(tagsProperty);

        Link tagsPropertyLink = getFirstLinkByRelation(tagsProperty, Relations.SELF);

        Assert.assertNotNull(tagsPropertyLink);

        PutMethod putMethod = executePut(tagsPropertyLink.getHref(), TAG_VALUE, MediaType.TEXT_PLAIN, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());

        getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                currentObject.getClassName(), currentObject.getNumber()).toString());
        Assert.assertEquals(HttpStatus.SC_OK, getMethod.getStatusCode());

        currentObject = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());

        tagsProperty = getProperty(currentObject, "tags");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.