Search in sources :

Example 46 with Package

use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.

the class PackageRepositoryValidationDecoratorTest method testUpdateValid.

@Test
public void testUpdateValid() throws Exception {
    Package package_ = mock(Package.class);
    packageRepositoryValidationDecorator.update(package_);
    verify(packageValidator).validate(package_);
    verify(delegateRepository).update(package_);
}
Also used : Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test)

Example 47 with Package

use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.

the class PackageRepositoryValidationDecoratorTest method testDeleteByIdValid.

@Test
public void testDeleteByIdValid() throws Exception {
    Package package_ = mock(Package.class);
    Object id = mock(Object.class);
    when(delegateRepository.findOneById(id)).thenReturn(package_);
    packageRepositoryValidationDecorator.deleteById(id);
    verify(packageValidator).validate(package_);
    verify(delegateRepository).deleteById(id);
}
Also used : Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test)

Example 48 with Package

use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.

the class PackageRepositoryValidationDecoratorTest method testDeleteAllStreamValid.

@SuppressWarnings("ResultOfMethodCallIgnored")
@Test
public void testDeleteAllStreamValid() throws Exception {
    Package package_ = mock(Package.class);
    Object id = mock(Object.class);
    when(delegateRepository.findOneById(id)).thenReturn(package_);
    packageRepositoryValidationDecorator.deleteAll(Stream.of(id));
    @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Object>> packageIdCaptor = ArgumentCaptor.forClass(Stream.class);
    verify(delegateRepository).deleteAll(packageIdCaptor.capture());
    packageIdCaptor.getValue().count();
    verify(packageValidator).validate(package_);
}
Also used : Stream(java.util.stream.Stream) Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test)

Example 49 with Package

use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.

the class PackageRepositoryValidationDecoratorTest method testDeleteByIdInvalid.

@Test(expectedExceptions = MolgenisValidationException.class)
public void testDeleteByIdInvalid() throws Exception {
    Package package_ = mock(Package.class);
    Object id = mock(Object.class);
    when(delegateRepository.findOneById(id)).thenReturn(package_);
    doThrow(mock(MolgenisValidationException.class)).when(packageValidator).validate(package_);
    packageRepositoryValidationDecorator.deleteById(id);
}
Also used : Package(org.molgenis.data.meta.model.Package) MolgenisValidationException(org.molgenis.data.validation.MolgenisValidationException) Test(org.testng.annotations.Test)

Example 50 with Package

use of org.molgenis.data.meta.model.Package in project molgenis by molgenis.

the class PackageRepositoryValidationDecoratorTest method testUpdateStreamInvalid.

@SuppressWarnings("ResultOfMethodCallIgnored")
@Test(expectedExceptions = MolgenisValidationException.class)
public void testUpdateStreamInvalid() throws Exception {
    Package package_ = mock(Package.class);
    doThrow(mock(MolgenisValidationException.class)).when(packageValidator).validate(package_);
    packageRepositoryValidationDecorator.update(Stream.of(package_));
    @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Package>> packageCaptor = ArgumentCaptor.forClass(Stream.class);
    verify(delegateRepository).update(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)

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