Search in sources :

Example 11 with Sheep

use of org.alfresco.rest.framework.tests.api.mocks.Sheep in project alfresco-remote-api by Alfresco.

the class SerializeTests method testSerializePagedCollection.

@SuppressWarnings({ "rawtypes" })
@Test
public void testSerializePagedCollection() throws IOException {
    assertNotNull(helper);
    CollectionWithPagingInfo paged = CollectionWithPagingInfo.asPaged(null, null);
    String out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api, null, Params.valueOf("notUsed", null, null), paged));
    assertTrue("There must be json output as List with pagination", StringUtils.startsWith(out, "{\"list\":{\"pagination\":{\"count\":0,"));
    Paging pageRequest = Paging.valueOf(1, 2);
    paged = CollectionWithPagingInfo.asPaged(pageRequest, Arrays.asList(new Goat(), new Sheep("ABCD"), new Sheep("XYZ")));
    out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api, null, Params.valueOf("notUsed", null, null), paged));
    assertTrue("There must be json output as List with pagination", StringUtils.startsWith(out, "{\"list\":{\"pagination\":{\"count\":3,"));
    paged = CollectionWithPagingInfo.asPaged(pageRequest, Arrays.asList(new Goat(), new Sheep("ABCD"), new Sheep("XYZ")), true, 5000);
    out = writeResponse(helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api, null, Params.valueOf("notUsed", null, null), paged));
    assertTrue("There must be json output as List with pagination", StringUtils.startsWith(out, "{\"list\":{\"pagination\":{\"count\":3,\"hasMoreItems\":true,\"totalItems\":5000"));
}
Also used : Paging(org.alfresco.rest.framework.resource.parameters.Paging) WebScriptResponse(org.springframework.extensions.webscripts.WebScriptResponse) CollectionWithPagingInfo(org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo) Sheep(org.alfresco.rest.framework.tests.api.mocks.Sheep) Goat(org.alfresco.rest.framework.tests.api.mocks.Goat) SlimGoat(org.alfresco.rest.framework.tests.api.mocks3.SlimGoat) Test(org.junit.Test)

Example 12 with Sheep

use of org.alfresco.rest.framework.tests.api.mocks.Sheep in project alfresco-remote-api by Alfresco.

the class SerializeTests method testSerializeSet.

@Test
public void testSerializeSet() throws IOException {
    assertNotNull(helper);
    Set<Object> aSet = new HashSet<Object>();
    aSet.add(new Goat());
    aSet.add(new Sheep("ABCD"));
    aSet.add(new Sheep("XYZ"));
    Object res = helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api, null, Params.valueOf("notUsed", null, null), aSet);
    String out = writeResponse(res);
    assertTrue("There must be json output", StringUtils.isNotBlank(out));
}
Also used : WebScriptResponse(org.springframework.extensions.webscripts.WebScriptResponse) Sheep(org.alfresco.rest.framework.tests.api.mocks.Sheep) JSONObject(org.json.JSONObject) Goat(org.alfresco.rest.framework.tests.api.mocks.Goat) SlimGoat(org.alfresco.rest.framework.tests.api.mocks3.SlimGoat) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with Sheep

use of org.alfresco.rest.framework.tests.api.mocks.Sheep in project alfresco-remote-api by Alfresco.

the class SerializeTests method testSerializeUniqueId.

@Test
public void testSerializeUniqueId() throws IOException {
    assertNotNull(helper);
    Object res = helper.processAdditionsToTheResponse(mock(WebScriptResponse.class), api, null, Params.valueOf("notUsed", null, null), new Sheep("ABCD"));
    String out = writeResponse(res);
    assertTrue("Id field must be called sheepGuid.", StringUtils.contains(out, "\"sheepGuid\":\"ABCD\""));
}
Also used : WebScriptResponse(org.springframework.extensions.webscripts.WebScriptResponse) Sheep(org.alfresco.rest.framework.tests.api.mocks.Sheep) JSONObject(org.json.JSONObject) Test(org.junit.Test)

Aggregations

Sheep (org.alfresco.rest.framework.tests.api.mocks.Sheep)13 Test (org.junit.Test)13 JSONObject (org.json.JSONObject)8 WebScriptResponse (org.springframework.extensions.webscripts.WebScriptResponse)8 Goat (org.alfresco.rest.framework.tests.api.mocks.Goat)7 SlimGoat (org.alfresco.rest.framework.tests.api.mocks3.SlimGoat)6 ExecutionResult (org.alfresco.rest.framework.jacksonextensions.ExecutionResult)4 HashMap (java.util.HashMap)3 Farmer (org.alfresco.rest.framework.tests.api.mocks.Farmer)3 ResourceMetadata (org.alfresco.rest.framework.core.ResourceMetadata)2 ResourceOperation (org.alfresco.rest.framework.core.ResourceOperation)2 ResourceParameter (org.alfresco.rest.framework.core.ResourceParameter)2 ResourceWithMetadata (org.alfresco.rest.framework.core.ResourceWithMetadata)2 Grass (org.alfresco.rest.framework.tests.api.mocks.Grass)2 MultiPartTestResponse (org.alfresco.rest.framework.tests.api.mocks.MultiPartTestResponse)2 AbstractResourceWebScript (org.alfresco.rest.framework.webscripts.AbstractResourceWebScript)2 WebScriptRequest (org.springframework.extensions.webscripts.WebScriptRequest)2 HashSet (java.util.HashSet)1 Api (org.alfresco.rest.framework.Api)1 BeanPropertiesFilter (org.alfresco.rest.framework.jacksonextensions.BeanPropertiesFilter)1