Search in sources :

Example 51 with Package

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

the class PackageRepositoryValidationDecoratorTest method testDeleteAllStreamInvalid.

@SuppressWarnings("ResultOfMethodCallIgnored")
@Test(expectedExceptions = MolgenisValidationException.class)
public void testDeleteAllStreamInvalid() 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.deleteAll(Stream.of(id));
    @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Object>> packageIdCaptor = ArgumentCaptor.forClass(Stream.class);
    verify(delegateRepository).deleteAll(packageIdCaptor.capture());
    packageIdCaptor.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 52 with Package

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

the class PackageRepositoryValidationDecoratorTest method testAddValid.

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

Example 53 with Package

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

the class PackageRepositoryValidationDecoratorTest method testAddStreamValid.

@Test
public void testAddStreamValid() throws Exception {
    Package package_ = mock(Package.class);
    packageRepositoryValidationDecorator.add(Stream.of(package_));
    @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Package>> packageCaptor = ArgumentCaptor.forClass(Stream.class);
    verify(delegateRepository).add(packageCaptor.capture());
    assertEquals(packageCaptor.getValue().collect(toList()), singletonList(package_));
    verify(packageValidator).validate(package_);
}
Also used : Stream(java.util.stream.Stream) Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test)

Example 54 with Package

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

the class PackageRepositoryValidationDecoratorTest method testUpdateStreamValid.

@Test
public void testUpdateStreamValid() throws Exception {
    Package package_ = mock(Package.class);
    packageRepositoryValidationDecorator.update(Stream.of(package_));
    @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Package>> packageCaptor = ArgumentCaptor.forClass(Stream.class);
    verify(delegateRepository).update(packageCaptor.capture());
    assertEquals(packageCaptor.getValue().collect(toList()), singletonList(package_));
    verify(packageValidator).validate(package_);
}
Also used : Stream(java.util.stream.Stream) Package(org.molgenis.data.meta.model.Package) Test(org.testng.annotations.Test)

Example 55 with Package

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

the class PackageRepositoryValidationDecoratorTest method testAddStreamInvalid.

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