### Question:
ResourceServiceHelper { protected ApiQuery addTypeCriteria(EntityDefinition entityDefinition, ApiQuery apiQuery) { if (apiQuery != null && entityDefinition != null) { if( !entityDefinition.getType().equals(entityDefinition.getStoredCollectionName())) { apiQuery.addCriteria(new NeutralCriteria("type", NeutralCriteria.CRITERIA_IN, Arrays.asList(entityDefinition.getDbType()), false)); } NeutralCriteria criteria = entityDefinition.getTypeCriteria(); if(criteria != null) { apiQuery.addCriteria(criteria); } } return apiQuery; }  ApiQuery getApiQuery(EntityDefinition definition, final URI requestURI); ApiQuery getApiQuery(EntityDefinition definition);  }### Answer:
@Test public void testAddTypeCriteria() { EntityDefinition def = entityDefs.lookupByResourceName(ResourceNames.TEACHERS); ApiQuery query = new ApiQuery(); query = resourceServiceHelper.addTypeCriteria(def, query); List<NeutralCriteria> criteriaList = query.getCriteria(); assertEquals("Should match", 1, criteriaList.size()); NeutralCriteria criteria = criteriaList.get(0); assertEquals("Should match", "type", criteria.getKey()); assertEquals("Should match", NeutralCriteria.CRITERIA_IN, criteria.getOperator()); assertEquals("Should match", Arrays.asList(def.getType()), criteria.getValue()); }
@Test public void testAddTypeCriteriaNoChange() { EntityDefinition def = entityDefs.lookupByResourceName(ResourceNames.STAFF); ApiQuery query = new ApiQuery(); query = resourceServiceHelper.addTypeCriteria(def, query); List<NeutralCriteria> criteriaList = query.getCriteria(); assertEquals("Should match", 0, criteriaList.size()); }
@Test public void testAddTypeCriteriaNullValues() { ApiQuery query = null; assertNull("Should be null", resourceServiceHelper.addTypeCriteria(null, null)); query = new ApiQuery(); query = resourceServiceHelper.addTypeCriteria(null, query); List<NeutralCriteria> criteriaList = query.getCriteria(); assertEquals("Should match", 0, criteriaList.size()); }