use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PermissionManagerController method updatePackagePermissions.
private void updatePackagePermissions(WebRequest webRequest, Sid sid) {
for (Package package_ : getPackages()) {
String param = "radio-" + package_.getId();
String value = webRequest.getParameter(param);
if (value != null) {
if (!value.equals("none")) {
createSidPackagePermission(package_, sid, toEntityTypePermission(value));
} else {
removeSidPackagePermission(package_, sid);
}
}
}
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaDataServiceImplTest method getRootPackages.
@Test
public void getRootPackages() {
Package package0 = mock(Package.class);
Package package1 = mock(Package.class);
@SuppressWarnings("unchecked") Query<Package> packageQ = mock(Query.class);
when(packageQ.eq(PARENT, null)).thenReturn(packageQ);
when(packageQ.findAll()).thenReturn(Stream.of(package0, package1));
when(dataService.query(PACKAGE, Package.class)).thenReturn(packageQ);
assertEquals(metaDataServiceImpl.getRootPackages(), newArrayList(package0, package1));
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaDataServiceImplTest method createRepositoryTyped.
@SuppressWarnings("unchecked")
@Test
public void createRepositoryTyped() {
String backendName = "backend";
Class<Package> entityClass = Package.class;
EntityType entityType = mock(EntityType.class);
when(entityType.getBackend()).thenReturn(backendName);
Attribute attr0 = mock(Attribute.class);
Attribute attr1 = mock(Attribute.class);
when(entityType.getOwnAllAttributes()).thenReturn(newArrayList(attr0, attr1));
RepositoryCollection repoCollection = mock(RepositoryCollection.class);
when(repoCollectionRegistry.getRepositoryCollection(backendName)).thenReturn(repoCollection);
Repository<Package> repo = mock(Repository.class);
when(repoCollection.getRepository(entityType)).thenReturn((Repository<Entity>) (Repository<?>) repo);
assertEquals(metaDataServiceImpl.createRepository(entityType, entityClass), repo);
ArgumentCaptor<Stream<Entity>> attrsCaptor = ArgumentCaptor.forClass(Stream.class);
verify(dataService).add(eq(ATTRIBUTE_META_DATA), attrsCaptor.capture());
assertEquals(attrsCaptor.getValue().collect(toList()), newArrayList(attr0, attr1));
verify(dataService).add(ENTITY_TYPE_META_DATA, entityType);
verifyNoMoreInteractions(dataService);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaDataServiceImplTest method getPackageString.
@Test
public void getPackageString() {
Package package_ = mock(Package.class);
String packageId = "package";
when(dataService.findOneById(PACKAGE, packageId, Package.class)).thenReturn(package_);
assertEquals(metaDataServiceImpl.getPackage(packageId), package_);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class MetaDataServiceImplTest method upsertPackages.
@Test
public void upsertPackages() {
Package package0 = mock(Package.class);
Package package1 = mock(Package.class);
metaDataServiceImpl.upsertPackages(Stream.of(package0, package1));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<Package>> captor = ArgumentCaptor.forClass(Stream.class);
verify(packagePersister).upsertPackages(captor.capture());
assertEquals(captor.getValue().collect(toList()), asList(package0, package1));
}
Aggregations