Search in sources :

Example 6 with Tag

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

the class TagRepositoryValidationDecoratorTest method testUpdateStreamInvalid.

@Test(expectedExceptions = MolgenisValidationException.class)
public void testUpdateStreamInvalid() throws Exception {
    Tag tag0 = mock(Tag.class);
    Tag tag1 = mock(Tag.class);
    doNothing().when(tagValidator).validate(tag0);
    doThrow(mock(MolgenisValidationException.class)).when(tagValidator).validate(tag1);
    tagRepositoryValidationDecorator.update(Stream.of(tag0, tag1));
    @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Tag>> tagCaptor = ArgumentCaptor.forClass(Stream.class);
    verify(delegateRepository).update(tagCaptor.capture());
    // consume stream
    tagCaptor.getValue().count();
}
Also used : Stream(java.util.stream.Stream) Tag(org.molgenis.data.meta.model.Tag) MolgenisValidationException(org.molgenis.data.validation.MolgenisValidationException) Test(org.testng.annotations.Test)

Example 7 with Tag

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

the class TagRepositoryValidationDecoratorTest method testAddStreamValid.

@Test
public void testAddStreamValid() throws Exception {
    Tag tag0 = mock(Tag.class);
    Tag tag1 = mock(Tag.class);
    doNothing().when(tagValidator).validate(tag0);
    doNothing().when(tagValidator).validate(tag1);
    tagRepositoryValidationDecorator.add(Stream.of(tag0, tag1));
    @SuppressWarnings("unchecked") ArgumentCaptor<Stream<Tag>> tagCaptor = ArgumentCaptor.forClass(Stream.class);
    verify(delegateRepository).add(tagCaptor.capture());
    assertEquals(tagCaptor.getValue().collect(toList()), asList(tag0, tag1));
    verify(tagValidator).validate(tag0);
    verify(tagValidator).validate(tag1);
}
Also used : Stream(java.util.stream.Stream) Tag(org.molgenis.data.meta.model.Tag) Test(org.testng.annotations.Test)

Example 8 with Tag

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

the class TagRepositoryValidationDecoratorTest method testAddValid.

@Test
public void testAddValid() throws Exception {
    Tag tag = mock(Tag.class);
    doNothing().when(tagValidator).validate(tag);
    tagRepositoryValidationDecorator.add(tag);
    verify(tagValidator).validate(tag);
    verify(delegateRepository).add(tag);
}
Also used : Tag(org.molgenis.data.meta.model.Tag) Test(org.testng.annotations.Test)

Example 9 with Tag

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

the class TagRepositoryValidationDecoratorTest method testUpdateValid.

@Test
public void testUpdateValid() throws Exception {
    Tag tag = mock(Tag.class);
    doNothing().when(tagValidator).validate(tag);
    tagRepositoryValidationDecorator.update(tag);
    verify(tagValidator).validate(tag);
    verify(delegateRepository).update(tag);
}
Also used : Tag(org.molgenis.data.meta.model.Tag) Test(org.testng.annotations.Test)

Example 10 with Tag

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

the class TagRepositoryValidationDecoratorTest method testAddInValid.

@Test(expectedExceptions = MolgenisValidationException.class)
public void testAddInValid() throws Exception {
    Tag tag = mock(Tag.class);
    doThrow(mock(MolgenisValidationException.class)).when(tagValidator).validate(tag);
    tagRepositoryValidationDecorator.add(tag);
}
Also used : Tag(org.molgenis.data.meta.model.Tag) MolgenisValidationException(org.molgenis.data.validation.MolgenisValidationException) Test(org.testng.annotations.Test)

Aggregations

Tag (org.molgenis.data.meta.model.Tag)18 Test (org.testng.annotations.Test)14 Stream (java.util.stream.Stream)4 MolgenisValidationException (org.molgenis.data.validation.MolgenisValidationException)4 EntityType (org.molgenis.data.meta.model.EntityType)3 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)2 Package (org.molgenis.data.meta.model.Package)2 EditorTagIdentifier (org.molgenis.metadata.manager.model.EditorTagIdentifier)2 Attribute (org.molgenis.data.meta.model.Attribute)1