@Test void testGetEntities() { EntityType entityType = mock(EntityType.class); RepositoryCollection repositoryCollection = mock(RepositoryCollection.class); @SuppressWarnings("unchecked") Repository<Entity> repository = mock(Repository.class); when(repository.spliterator()).thenReturn(Collections.<Entity>emptyList().spliterator()); when(repositoryCollection.getRepository(entityType)).thenReturn(repository); when(emxImportJob.getSource()).thenReturn(repositoryCollection); assertEquals(emptyList(), 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);  }