use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageValidatorTest method testValidatePackageValidName.
@Test
public void testValidatePackageValidName() throws Exception {
Package package_ = when(mock(Package.class).getId()).thenReturn("test_myPackage").getMock();
when(package_.getParent()).thenReturn(testPackage);
when(package_.getRootPackage()).thenReturn(testPackage);
packageValidator.validate(package_);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageValidatorTest method testValidateSystemPackageInRegistry.
@Test
public void testValidateSystemPackageInRegistry() throws Exception {
Package package_ = when(mock(Package.class).getId()).thenReturn(PACKAGE_SYSTEM + '_' + "myPackage").getMock();
when(package_.getParent()).thenReturn(systemPackage);
when(package_.getRootPackage()).thenReturn(systemPackage);
when(systemPackageRegistry.containsPackage(package_)).thenReturn(true);
packageValidator.validate(package_);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageRepositorySecurityDecoratorTest method testUpdate.
@Test
public void testUpdate() {
Package pack = mock(Package.class);
Package parent = mock(Package.class);
when(pack.getId()).thenReturn("1");
when(parent.getId()).thenReturn("2");
when(pack.getParent()).thenReturn(parent);
MutableAcl acl = mock(MutableAcl.class);
MutableAcl parentAcl = mock(MutableAcl.class);
when(mutableAclService.readAclById(any())).thenAnswer(invocation -> {
Object argument = invocation.getArguments()[0];
if (argument.equals(new PackageIdentity("1"))) {
return acl;
} else if (argument.equals(new PackageIdentity("2"))) {
return parentAcl;
}
return null;
});
repo.update(pack);
verify(mutableAclService).updateAcl(acl);
verify(delegateRepository).update(pack);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageRepositorySecurityDecoratorTest method testDelete1.
@Test
public void testDelete1() {
Package package1 = mock(Package.class);
Package package2 = mock(Package.class);
when(package1.getId()).thenReturn("1");
when(package2.getId()).thenReturn("2");
Stream<Package> packages = Stream.of(package1, package2);
repo.delete(packages);
// TODO: how to verify the deleteAcl method in the "filter" of the stream
ArgumentCaptor<Stream<Package>> captor = ArgumentCaptor.forClass(Stream.class);
verify(delegateRepository).delete(captor.capture());
assertEquals(captor.getValue().collect(toList()), asList(package1, package2));
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageRepositorySecurityDecoratorTest method testDelete.
@Test
public void testDelete() {
Package pack = mock(Package.class);
when(pack.getId()).thenReturn("1");
repo.delete(pack);
verify(mutableAclService).deleteAcl(new PackageIdentity("1"), true);
verify(delegateRepository).delete(pack);
}
Aggregations