@Test void getRepositories() { String backendName0 = "backend0"; String backendName1 = "backend1"; EntityType entityType0 = mock(EntityType.class); when(entityType0.getBackend()).thenReturn(backendName0); EntityType entityType1 = mock(EntityType.class); when(entityType1.getBackend()).thenReturn(backendName1); @SuppressWarnings("unchecked") Query<EntityType> entityQ = mock(Query.class); when(entityQ.eq(IS_ABSTRACT, false)).thenReturn(entityQ); when(entityQ.fetch(any())).thenReturn(entityQ); when(entityQ.findAll()).thenReturn(Stream.of(entityType0, entityType1)); when(dataService.query(ENTITY_TYPE_META_DATA, EntityType.class)).thenReturn(entityQ); RepositoryCollection repoCollection0 = mock(RepositoryCollection.class); @SuppressWarnings("unchecked") Repository<Entity> repo0 = mock(Repository.class); when(repoCollection0.getRepository(entityType0)).thenReturn(repo0); doReturn(repoCollection0).when(repoCollectionRegistry).getRepositoryCollection(backendName0); @SuppressWarnings("unchecked") Repository<Entity> repo1 = mock(Repository.class); RepositoryCollection repoCollection1 = mock(RepositoryCollection.class); when(repoCollection1.getRepository(entityType1)).thenReturn(repo1); doReturn(repoCollection1).when(repoCollectionRegistry).getRepositoryCollection(backendName1); List<Repository<Entity>> expectedRepos = newArrayList(repo0, repo1); assertEquals(expectedRepos, metaDataServiceImpl.getRepositories().collect(toList())); }
@Override public Stream<Repository<Entity>> getRepositories() { return dataService .query(ENTITY_TYPE_META_DATA, EntityType.class) .eq(IS_ABSTRACT, false) .fetch(getEntityTypeFetch()) .findAll() .map( entityType -> this.getRepository(entityType) .orElseThrow(() -> new UnknownRepositoryException(entityType.getId()))); }
MetaDataServiceImpl implements MetaDataService { @Override public Stream<Repository<Entity>> getRepositories() { return dataService .query(ENTITY_TYPE_META_DATA, EntityType.class) .eq(IS_ABSTRACT, false) .fetch(getEntityTypeFetch()) .findAll() .map( entityType -> this.getRepository(entityType) .orElseThrow(() -> new UnknownRepositoryException(entityType.getId()))); } }
MetaDataServiceImpl implements MetaDataService { @Override public Stream<Repository<Entity>> getRepositories() { return dataService .query(ENTITY_TYPE_META_DATA, EntityType.class) .eq(IS_ABSTRACT, false) .fetch(getEntityTypeFetch()) .findAll() .map( entityType -> this.getRepository(entityType) .orElseThrow(() -> new UnknownRepositoryException(entityType.getId()))); } MetaDataServiceImpl(
      DataService dataService,
      RepositoryCollectionRegistry repoCollectionRegistry,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      EntityTypeDependencyResolver entityTypeDependencyResolver,
      PackagePersister packagePersister); }
MetaDataServiceImpl implements MetaDataService { @Override public Stream<Repository<Entity>> getRepositories() { return dataService .query(ENTITY_TYPE_META_DATA, EntityType.class) .eq(IS_ABSTRACT, false) .fetch(getEntityTypeFetch()) .findAll() .map( entityType -> this.getRepository(entityType) .orElseThrow(() -> new UnknownRepositoryException(entityType.getId()))); } MetaDataServiceImpl(
      DataService dataService,
      RepositoryCollectionRegistry repoCollectionRegistry,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      EntityTypeDependencyResolver entityTypeDependencyResolver,
      PackagePersister packagePersister); @Override Optional<Repository<Entity>> getRepository(String entityTypeId); @SuppressWarnings("unchecked") @Override Optional<Repository<E>> getRepository(
      String entityTypeId, Class<E> entityClass); @Override Optional<Repository<Entity>> getRepository(EntityType entityType); @SuppressWarnings("unchecked") @Override Optional<Repository<E>> getRepository(
      EntityType entityType, Class<E> entityClass); @Override boolean hasRepository(String entityTypeId); @Transactional @Override Repository<Entity> createRepository(EntityType entityType); @Transactional @Override Repository<E> createRepository(
      EntityType entityType, Class<E> entityClass); @Override RepositoryCollection getDefaultBackend(); @Override RepositoryCollection getBackend(String backendName); @Transactional @Override void deleteEntityType(String entityTypeId); @Transactional @Override void deleteEntityTypes(Collection<String> entityTypeIds); @Transactional @Override void deleteAttributeById(Object id); @Override RepositoryCollection getBackend(EntityType entityType); @Transactional @Override void addEntityType(EntityType entityType); @Transactional @Override void updateEntityType(EntityType entityType); @Transactional @Override void upsertEntityTypes(Collection<EntityType> entityTypes); @Transactional @Override void addAttribute(Attribute attr); @Override boolean hasEntityType(String entityTypeId); @Override Optional<EntityType> getEntityType(String entityTypeId); @Transactional @Override void addPackage(Package aPackage); @Transactional @Override void upsertPackages(Stream<Package> packages); @Override Optional<Package> getPackage(String packageId); @Override List<Package> getPackages(); @Override List<Package> getRootPackages(); @Transactional @Override void upsertTags(Collection<Tag> tags); @Override Stream<EntityType> getEntityTypes(); @Override Stream<Repository<Entity>> getRepositories(); @Override @Nonnull Iterator<RepositoryCollection> iterator(); @Override Map<String, Boolean> determineImportableEntities(
      RepositoryCollection repositoryCollection); @Override boolean isEntityTypeCompatible(EntityType newEntityType); @Override boolean hasBackend(String backendName); @Override Stream<EntityType> getConcreteChildren(EntityType entityType); @Override Stream<Attribute> getReferringAttributes(String entityTypeId); }
MetaDataServiceImpl implements MetaDataService { @Override public Stream<Repository<Entity>> getRepositories() { return dataService .query(ENTITY_TYPE_META_DATA, EntityType.class) .eq(IS_ABSTRACT, false) .fetch(getEntityTypeFetch()) .findAll() .map( entityType -> this.getRepository(entityType) .orElseThrow(() -> new UnknownRepositoryException(entityType.getId()))); } MetaDataServiceImpl(
      DataService dataService,
      RepositoryCollectionRegistry repoCollectionRegistry,
      SystemEntityTypeRegistry systemEntityTypeRegistry,
      EntityTypeDependencyResolver entityTypeDependencyResolver,
      PackagePersister packagePersister); @Override Optional<Repository<Entity>> getRepository(String entityTypeId); @SuppressWarnings("unchecked") @Override Optional<Repository<E>> getRepository(
      String entityTypeId, Class<E> entityClass); @Override Optional<Repository<Entity>> getRepository(EntityType entityType); @SuppressWarnings("unchecked") @Override Optional<Repository<E>> getRepository(
      EntityType entityType, Class<E> entityClass); @Override boolean hasRepository(String entityTypeId); @Transactional @Override Repository<Entity> createRepository(EntityType entityType); @Transactional @Override Repository<E> createRepository(
      EntityType entityType, Class<E> entityClass); @Override RepositoryCollection getDefaultBackend(); @Override RepositoryCollection getBackend(String backendName); @Transactional @Override void deleteEntityType(String entityTypeId); @Transactional @Override void deleteEntityTypes(Collection<String> entityTypeIds); @Transactional @Override void deleteAttributeById(Object id); @Override RepositoryCollection getBackend(EntityType entityType); @Transactional @Override void addEntityType(EntityType entityType); @Transactional @Override void updateEntityType(EntityType entityType); @Transactional @Override void upsertEntityTypes(Collection<EntityType> entityTypes); @Transactional @Override void addAttribute(Attribute attr); @Override boolean hasEntityType(String entityTypeId); @Override Optional<EntityType> getEntityType(String entityTypeId); @Transactional @Override void addPackage(Package aPackage); @Transactional @Override void upsertPackages(Stream<Package> packages); @Override Optional<Package> getPackage(String packageId); @Override List<Package> getPackages(); @Override List<Package> getRootPackages(); @Transactional @Override void upsertTags(Collection<Tag> tags); @Override Stream<EntityType> getEntityTypes(); @Override Stream<Repository<Entity>> getRepositories(); @Override @Nonnull Iterator<RepositoryCollection> iterator(); @Override Map<String, Boolean> determineImportableEntities(
      RepositoryCollection repositoryCollection); @Override boolean isEntityTypeCompatible(EntityType newEntityType); @Override boolean hasBackend(String backendName); @Override Stream<EntityType> getConcreteChildren(EntityType entityType); @Override Stream<Attribute> getReferringAttributes(String entityTypeId);  }