KindsServiceImpl implements KindsService { @Override public List<String> getKinds(String namespace) { AppEngineHelper.disableApiHooks(); Iterable<Entity> entityIterable = datastoreHelper .queryOnNamespace(namespace, new Query(Entities.KIND_METADATA_KIND)); return getKinds(entityIterable); } @Inject  KindsServiceImpl(
            DatastoreHelper datastoreHelper); @Override List<String> getKinds(String namespace);  }
@Test public void getKinds_twoKindsStored_shouldReturnTheTwoKinds() { createEntityInDatastore(KIND_NAME, PROPERTY_NAME, A_NAME); createEntityInDatastore(ANOTHER_KIND, PROPERTY_NAME, ANOTHER_NAME); List<String> kindsList = kindsService.getKinds(null); assertEquals(2, kindsList.size()); assertTrue(kindsList.contains(KIND_NAME)); assertTrue(kindsList.contains(ANOTHER_KIND)); }
@Test public void getKinds_withNamespace_shouldReturnOnlyOneKind() { createEntityInDatastore(KIND_NAME, PROPERTY_NAME, A_NAME); createEntityInNamespace(SOME_NAMESPACE, ANOTHER_KIND, PROPERTY_NAME, ANOTHER_NAME); List<String> kindsList = kindsService.getKinds(SOME_NAMESPACE); assertEquals(1, kindsList.size()); assertTrue(kindsList.contains(ANOTHER_KIND)); }
@Test public void getKinds_withDefaultNamespace_shouldReturnOnlyOneKind() { createEntityInDatastore(KIND_NAME, PROPERTY_NAME, A_NAME); createEntityInNamespace(SOME_NAMESPACE, ANOTHER_KIND, PROPERTY_NAME, ANOTHER_NAME); List<String> kindsList = kindsService.getKinds(""); assertEquals(1, kindsList.size()); assertTrue(kindsList.contains(KIND_NAME)); }
@Test public void getKinds_threeKindsStored_gaeKind_shouldReturnTheTwoKinds() { createEntityInDatastore(KIND_NAME, PROPERTY_NAME, A_NAME); createEntityInDatastore(ANOTHER_KIND, PROPERTY_NAME, ANOTHER_NAME); createEntityInDatastore(GAE_KIND_NAME, PROPERTY_NAME, ANOTHER_NAME); List<String> kindsList = kindsService.getKinds(null); assertEquals(2, kindsList.size()); assertTrue(kindsList.contains(KIND_NAME)); assertTrue(kindsList.contains(ANOTHER_KIND)); }