use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageRepositoryValidationDecoratorTest method testDeleteStreamInvalid.
@SuppressWarnings("ResultOfMethodCallIgnored")
@Test(expectedExceptions = MolgenisValidationException.class)
public void testDeleteStreamInvalid() throws Exception {
Package package_ = mock(Package.class);
doThrow(mock(MolgenisValidationException.class)).when(packageValidator).validate(package_);
packageRepositoryValidationDecorator.delete(Stream.of(package_));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<Package>> packageCaptor = ArgumentCaptor.forClass(Stream.class);
verify(delegateRepository).delete(packageCaptor.capture());
packageCaptor.getValue().count();
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageRepositoryValidationDecoratorTest method testDeleteAllInvalid.
@Test(expectedExceptions = MolgenisValidationException.class)
public void testDeleteAllInvalid() throws Exception {
Package package_ = mock(Package.class);
when(delegateRepository.iterator()).thenReturn(singletonList(package_).iterator());
doThrow(mock(MolgenisValidationException.class)).when(packageValidator).validate(package_);
packageRepositoryValidationDecorator.deleteAll();
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageValidatorTest method testValidatePackageInvalidName.
@Test(expectedExceptions = MolgenisDataException.class, expectedExceptionsMessageRegExp = "Invalid name: \\[0package\\] Names must start with a letter.")
public void testValidatePackageInvalidName() throws Exception {
Package package_ = when(mock(Package.class).getId()).thenReturn("0package").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 testValidateSystemPackageNotInRegistry.
@Test(expectedExceptions = MolgenisValidationException.class, expectedExceptionsMessageRegExp = "Modifying system packages is not allowed")
public void testValidateSystemPackageNotInRegistry() 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(false);
packageValidator.validate(package_);
}
use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.
the class PackageValidatorTest method testValidateNonSystemPackage.
@Test
public void testValidateNonSystemPackage() throws Exception {
Package package_ = when(mock(Package.class).getId()).thenReturn("myPackage").getMock();
when(systemPackageRegistry.containsPackage(package_)).thenReturn(false);
packageValidator.validate(package_);
}
Aggregations