EntitiesServiceImpl implements EntitiesService { @Override public long getCount(String kind, String namespace) { AppEngineHelper.disableApiHooks(); return countProvider.get(kind, namespace); } @Inject  EntitiesServiceImpl(
            DatastoreHelper datastoreHelper,
            DefaultValueGenerator defaultValueGenerator,
            DatastoreCountProvider countProvider); @Override Iterable<Entity> getEntities(String kind, String namespace, Integer offset, Integer limit); @Override Collection<Entity> getEntities(List<Key> keys); @Override Entity createEmptyEntity(String kind); @Override void deleteEntities(String kind, String namespace, DeleteEntities deleteType, String encodedKeys); @Override long getCount(String kind, String namespace); @Override List<Key> put(Iterable<Entity> entities); @Override Future<List<Key>> putAsync(Iterable<Entity> entities);  }
@Test public void getCount_withNamespace_shouldReturnOneEntity() { createEntityInDatastore(KIND_NAME, PROPERTY_NAME, A_NAME); createEntityInNamespace(A_NAMESPACE, KIND_NAME, PROPERTY_NAME, ANOTHER_NAME); long entityCount = entitiesService.getCount(KIND_NAME, A_NAMESPACE); assertEquals(1L, entityCount); }
@Test public void getCount_withDefaultNamespace_shouldReturnOneEntity() { createEntityInDatastore(KIND_NAME, PROPERTY_NAME, A_NAME); createEntityInNamespace(A_NAMESPACE, KIND_NAME, PROPERTY_NAME, ANOTHER_NAME); long entityCount = entitiesService.getCount(KIND_NAME, DEFAULT_NAMESPACE); assertEquals(1L, entityCount); }
@Test public void getCount_twoEntitiesStored_shouldReturnTwoEntities() { createEntityInDatastore(KIND_NAME, PROPERTY_NAME, A_NAME); createEntityInDatastore(KIND_NAME, PROPERTY_NAME, ANOTHER_NAME); long entityCount = entitiesService.getCount(KIND_NAME, ALL_NAMESPACES); assertEquals(2L, entityCount); }