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();
}
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_);
}
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_);
}
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_);
}
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();
}
Aggregations