@Test void testGetEntitiesAlternativeEntityTypeIdUnknownRepository() { String entityTypeId = "base_EntityTypeId"; EntityType entityType = when(mock(EntityType.class).getId()).thenReturn(entityTypeId).getMock(); RepositoryCollection repositoryCollection = mock(RepositoryCollection.class); doThrow(new UnknownRepositoryException("EntityTypeId")) .when(repositoryCollection) .getRepository("EntityTypeId"); when(emxImportJob.getSource()).thenReturn(repositoryCollection); assertThrows( UnknownRepositoryException.class, () -> emxDataProvider.getEntities(entityType).collect(toList())); }
@Override public Stream<Entity> getEntities(EntityType entityType) { Repository<Entity> repository = job.getSource().getRepository(entityType); if (repository == null) { Optional<String> packageId = job.getPackageId(); if (packageId.isPresent() && entityType.getId().startsWith(packageId.get() + PACKAGE_SEPARATOR)) { repository = job.getSource() .getRepository( entityType .getId() .substring(packageId.get().length() + PACKAGE_SEPARATOR.length())); } } if (repository == null) { throw new UnknownRepositoryException(entityType.getId()); } return stream(repository).map(sourceEntity -> toEntity(entityType, sourceEntity)); }
EmxDataProvider implements DataProvider { @Override public Stream<Entity> getEntities(EntityType entityType) { Repository<Entity> repository = job.getSource().getRepository(entityType); if (repository == null) { Optional<String> packageId = job.getPackageId(); if (packageId.isPresent() && entityType.getId().startsWith(packageId.get() + PACKAGE_SEPARATOR)) { repository = job.getSource() .getRepository( entityType .getId() .substring(packageId.get().length() + PACKAGE_SEPARATOR.length())); } } if (repository == null) { throw new UnknownRepositoryException(entityType.getId()); } return stream(repository).map(sourceEntity -> toEntity(entityType, sourceEntity)); } }
EmxDataProvider implements DataProvider { @Override public Stream<Entity> getEntities(EntityType entityType) { Repository<Entity> repository = job.getSource().getRepository(entityType); if (repository == null) { Optional<String> packageId = job.getPackageId(); if (packageId.isPresent() && entityType.getId().startsWith(packageId.get() + PACKAGE_SEPARATOR)) { repository = job.getSource() .getRepository( entityType .getId() .substring(packageId.get().length() + PACKAGE_SEPARATOR.length())); } } if (repository == null) { throw new UnknownRepositoryException(entityType.getId()); } return stream(repository).map(sourceEntity -> toEntity(entityType, sourceEntity)); } EmxDataProvider(EmxImportJob job, EntityManager entityManager); }
EmxDataProvider implements DataProvider { @Override public Stream<Entity> getEntities(EntityType entityType) { Repository<Entity> repository = job.getSource().getRepository(entityType); if (repository == null) { Optional<String> packageId = job.getPackageId(); if (packageId.isPresent() && entityType.getId().startsWith(packageId.get() + PACKAGE_SEPARATOR)) { repository = job.getSource() .getRepository( entityType .getId() .substring(packageId.get().length() + PACKAGE_SEPARATOR.length())); } } if (repository == null) { throw new UnknownRepositoryException(entityType.getId()); } return stream(repository).map(sourceEntity -> toEntity(entityType, sourceEntity)); } EmxDataProvider(EmxImportJob job, EntityManager entityManager); @Override Stream<EntityType> getEntityTypes(); @Override boolean hasEntities(EntityType entityType); @Override Stream<Entity> getEntities(EntityType entityType); }
EmxDataProvider implements DataProvider { @Override public Stream<Entity> getEntities(EntityType entityType) { Repository<Entity> repository = job.getSource().getRepository(entityType); if (repository == null) { Optional<String> packageId = job.getPackageId(); if (packageId.isPresent() && entityType.getId().startsWith(packageId.get() + PACKAGE_SEPARATOR)) { repository = job.getSource() .getRepository( entityType .getId() .substring(packageId.get().length() + PACKAGE_SEPARATOR.length())); } } if (repository == null) { throw new UnknownRepositoryException(entityType.getId()); } return stream(repository).map(sourceEntity -> toEntity(entityType, sourceEntity)); } EmxDataProvider(EmxImportJob job, EntityManager entityManager); @Override Stream<EntityType> getEntityTypes(); @Override boolean hasEntities(EntityType entityType); @Override Stream<Entity> getEntities(EntityType entityType);  }