use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaDataServiceImplTest method addPackage.
@Test
public void addPackage() {
Package package_ = mock(Package.class);
metaDataServiceImpl.addPackage(package_);
verify(dataService).add(PACKAGE, package_);
verifyNoMoreInteractions(dataService);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaDataServiceImplTest method getRepositoryTypedEntityType.
@SuppressWarnings("unchecked")
@Test
public void getRepositoryTypedEntityType() {
EntityType entityType = when(mock(EntityType.class).isAbstract()).thenReturn(false).getMock();
String backendName = "backend";
when(entityType.getBackend()).thenReturn(backendName);
RepositoryCollection repoCollection = mock(RepositoryCollection.class);
Repository<Package> repo = mock(Repository.class);
when(repoCollection.getRepository(entityType)).thenReturn((Repository<Entity>) (Repository<?>) repo);
when(repoCollectionRegistry.getRepositoryCollection(backendName)).thenReturn(repoCollection);
assertEquals(metaDataServiceImpl.getRepository(entityType, Package.class), repo);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaUtilsTest method isSystemPackageTrueNested.
@Test
public void isSystemPackageTrueNested() {
Package rootPackage_ = mock(Package.class);
when(rootPackage_.getId()).thenReturn(PACKAGE_SYSTEM);
Package package_ = mock(Package.class);
when(package_.getId()).thenReturn("systemChild");
when(package_.getRootPackage()).thenReturn(rootPackage_);
assertTrue(MetaUtils.isSystemPackage(package_));
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaUtilsTest method isSystemPackageFalse.
@Test
public void isSystemPackageFalse() {
Package package_ = mock(Package.class);
when(package_.getId()).thenReturn("notSystem");
assertFalse(MetaUtils.isSystemPackage(package_));
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackagePersisterTest method testUpsertPackages.
@Test
public void testUpsertPackages() throws Exception {
String newPackageName = "newPackage";
String unchangedPackageName = "unchangedPackage";
String updatedPackageName = "updatedPackage";
Package newPackage = mock(Package.class);
when(newPackage.getId()).thenReturn("newPackageId");
Package unchangedPackage = mock(Package.class);
when(unchangedPackage.getId()).thenReturn("unchangedPackageId");
Package updatedPackage = mock(Package.class);
when(updatedPackage.getId()).thenReturn("updatedPackageId");
Package existingUpdatedPackage = mock(Package.class);
when(existingUpdatedPackage.getId()).thenReturn("updatedPackageId");
@SuppressWarnings("unchecked") Query<Package> query = mock(Query.class);
when(dataService.query(PACKAGE, Package.class)).thenReturn(query);
when(query.in(eq(PackageMetadata.ID), any(Set.class))).thenReturn(query);
when(query.findAll()).thenReturn(Stream.of(unchangedPackage, existingUpdatedPackage));
packagePersister.upsertPackages(Stream.of(newPackage, unchangedPackage, updatedPackage));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<Package>> addCaptor = ArgumentCaptor.forClass(Stream.class);
verify(dataService).add(eq(PACKAGE), addCaptor.capture());
assertEquals(addCaptor.getValue().collect(toList()), singletonList(newPackage));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<Package>> updateCaptor = ArgumentCaptor.forClass(Stream.class);
verify(dataService).update(eq(PACKAGE), updateCaptor.capture());
assertEquals(updateCaptor.getValue().collect(toList()), singletonList(updatedPackage));
}
Aggregations