Search in sources :

Example 56 with Package

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();
}
Also used : Stream(java.util.stream.Stream) Package(org.molgenis.data.meta.model.Package) MolgenisValidationException(org.molgenis.data.validation.MolgenisValidationException) Test(org.testng.annotations.Test)

Example 57 with Package

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();
}
Also used : Package(org.molgenis.data.meta.model.Package) MolgenisValidationException(org.molgenis.data.validation.MolgenisValidationException) Test(org.testng.annotations.Test)

Example 58 with Package

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_);
}
Also used : Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test)

Example 59 with 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_);
}
Also used : Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test)

Example 60 with 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_);
}
Also used : Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test)

Aggregations

Package (org.molgenis.data.meta.model.Package)98 Test (org.testng.annotations.Test)70 EntityType (org.molgenis.data.meta.model.EntityType)22 Stream (java.util.stream.Stream)20 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)13 Attribute (org.molgenis.data.meta.model.Attribute)11 DefaultPackage (org.molgenis.data.meta.DefaultPackage)10 MolgenisValidationException (org.molgenis.data.validation.MolgenisValidationException)10 Objects.requireNonNull (java.util.Objects.requireNonNull)6 L10nString (org.molgenis.data.i18n.model.L10nString)6 PackageIdentity (org.molgenis.data.security.PackageIdentity)6 Collectors.toList (java.util.stream.Collectors.toList)5 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)5 DataService (org.molgenis.data.DataService)5 QueryImpl (org.molgenis.data.support.QueryImpl)5 RepositoryCollection (org.molgenis.data.RepositoryCollection)4 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)3 java.util (java.util)3 Collections.singletonList (java.util.Collections.singletonList)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3