use of org.alfresco.rest.framework.webscripts.ParamsExtractor in project alfresco-remote-api by Alfresco.
the class ParamsExtractorTests method testDeleteExtractor.
@Test
public void testDeleteExtractor() throws IOException {
ParamsExtractor extractor = new ResourceWebScriptDelete();
Map<String, String> templateVars = new HashMap<String, String>();
WebScriptRequest request = mock(WebScriptRequest.class);
when(request.getServiceMatch()).thenReturn(new Match(null, templateVars, null));
Params params = null;
params = extractor.extractParams(mockEntity(), request);
assertNotNull(params);
assertNull(params.getEntityId());
assertNull(params.getRelationshipId());
assertNotNull(params.getFilter());
assertTrue("Default filter is BeanPropertiesFilter.AllProperties", BeanPropertiesFilter.AllProperties.class.equals(params.getFilter().getClass()));
templateVars.put(ResourceLocator.ENTITY_ID, "1234");
params = extractor.extractParams(mockRelationship(), request);
assertNotNull(params);
assertEquals("1234", params.getEntityId());
assertNull(params.getRelationshipId());
assertNotNull(params.getFilter());
assertTrue("Default filter is BeanPropertiesFilter.AllProperties", BeanPropertiesFilter.AllProperties.class.equals(params.getFilter().getClass()));
templateVars.put(ResourceLocator.RELATIONSHIP_ID, "45678");
params = extractor.extractParams(mockRelationship(), request);
assertNotNull(params);
assertEquals("1234", params.getEntityId());
assertEquals("45678", params.getRelationshipId());
assertNotNull(params.getFilter());
assertTrue("Default filter is BeanPropertiesFilter.AllProperties", BeanPropertiesFilter.AllProperties.class.equals(params.getFilter().getClass()));
testExtractAddressedParams(templateVars, request, extractor);
}
use of org.alfresco.rest.framework.webscripts.ParamsExtractor in project alfresco-remote-api by Alfresco.
the class ParamsExtractorTests method testGetExtractor.
@Test
public void testGetExtractor() {
ParamsExtractor extractor = new ResourceWebScriptGet();
Map<String, String> templateVars = new HashMap<String, String>();
WebScriptRequest request = mock(WebScriptRequest.class);
when(request.getServiceMatch()).thenReturn(new Match(null, templateVars, null));
Params params = extractor.extractParams(mockEntity(), request);
assertNull("For getting a Collection there should be no entity params.", params.getEntityId());
assertNull("For getting a Collection there should be no passed params.", params.getPassedIn());
assertNull("For getting a Collection there should be no relationshipId params.", params.getRelationshipId());
assertEquals(Paging.DEFAULT_SKIP_COUNT, params.getPaging().getSkipCount());
assertEquals(Paging.DEFAULT_MAX_ITEMS, params.getPaging().getMaxItems());
assertNotNull(params.getFilter());
assertTrue("Default filter is BeanPropertiesFilter.AllProperties", BeanPropertiesFilter.AllProperties.class.equals(params.getFilter().getClass()));
templateVars.put(ResourceLocator.ENTITY_ID, "1234");
params = extractor.extractParams(mockEntity(), request);
assertNotNull(params);
assertNotNull(params.getRelationsFilter());
assertFalse(params.includeSource());
templateVars.put(ResourceLocator.RELATIONSHIP_RESOURCE, "codfish");
params = extractor.extractParams(mockRelationship(), request);
assertNotNull(params);
assertNull("For getting a Collection there should be no relationshipId params.", params.getRelationshipId());
templateVars.put(ResourceLocator.RELATIONSHIP_ID, "45678");
params = extractor.extractParams(mockRelationship(), request);
assertNotNull(params);
assertEquals("1234", params.getEntityId());
assertEquals("45678", params.getRelationshipId());
assertFalse(params.includeSource());
testExtractAddressedParams(templateVars, request, extractor);
}
Aggregations