Search in sources :

Example 1 with ConsumerProducerFunction

use of uk.gov.gchq.gaffer.function.ConsumerProducerFunction in project Gaffer by gchq.

the class ConsumerProducerFunctionContextTest method shouldThrowExceptionWhenBuildContextWhenSelectCalledTwice.

@Test
public void shouldThrowExceptionWhenBuildContextWhenSelectCalledTwice() {
    // Given
    final String reference1 = "reference 1";
    final String reference2 = "reference 2";
    final ConsumerProducerFunction func1 = mock(ConsumerProducerFunction.class);
    final String reference1Proj = "reference 2 proj";
    final String reference2Proj = "reference 2 proj";
    // When / Then
    try {
        new ConsumerProducerFunctionContext.Builder<String, ConsumerProducerFunction>().select(reference1).execute(func1).project(reference1Proj, reference2Proj).select(reference2).build();
        fail("Exception expected");
    } catch (final IllegalStateException e) {
        assertNotNull(e);
    }
}
Also used : ConsumerProducerFunction(uk.gov.gchq.gaffer.function.ConsumerProducerFunction) Test(org.junit.Test)

Example 2 with ConsumerProducerFunction

use of uk.gov.gchq.gaffer.function.ConsumerProducerFunction in project Gaffer by gchq.

the class ConsumerProducerFunctionContextTest method shouldThrowExceptionWhenBuildContextWhenExecuteCalledTwice.

@Test
public void shouldThrowExceptionWhenBuildContextWhenExecuteCalledTwice() {
    // Given
    final String reference1 = "reference 1";
    final ConsumerProducerFunction func1 = mock(ConsumerProducerFunction.class);
    final ConsumerProducerFunction func2 = mock(ConsumerProducerFunction.class);
    final String reference1Proj = "reference 2 proj";
    final String reference2Proj = "reference 2 proj";
    // When / Then
    try {
        new ConsumerProducerFunctionContext.Builder<String, ConsumerProducerFunction>().select(reference1).execute(func1).project(reference1Proj, reference2Proj).execute(func2).build();
        fail("Exception expected");
    } catch (final IllegalStateException e) {
        assertNotNull(e);
    }
}
Also used : ConsumerProducerFunction(uk.gov.gchq.gaffer.function.ConsumerProducerFunction) Test(org.junit.Test)

Example 3 with ConsumerProducerFunction

use of uk.gov.gchq.gaffer.function.ConsumerProducerFunction in project Gaffer by gchq.

the class PassThroughFunctionContextTest method shouldThrowExceptionWhenBuildContextWhenExecuteCalledTwice.

@Test
public void shouldThrowExceptionWhenBuildContextWhenExecuteCalledTwice() {
    // Given
    final String reference1 = "reference 1";
    final ConsumerProducerFunction func1 = mock(ConsumerProducerFunction.class);
    final ConsumerProducerFunction func2 = mock(ConsumerProducerFunction.class);
    // When / Then
    try {
        new PassThroughFunctionContext.Builder<String, ConsumerProducerFunction>().select(reference1).execute(func1).execute(func2).build();
        fail("Exception expected");
    } catch (final IllegalStateException e) {
        assertNotNull(e);
    }
}
Also used : ConsumerProducerFunction(uk.gov.gchq.gaffer.function.ConsumerProducerFunction) Test(org.junit.Test)

Example 4 with ConsumerProducerFunction

use of uk.gov.gchq.gaffer.function.ConsumerProducerFunction in project Gaffer by gchq.

the class PassThroughFunctionContextTest method shouldBuildContext.

@Test
public void shouldBuildContext() {
    // Given
    final String reference1 = "reference 1";
    final String reference2 = "reference 2";
    final ConsumerProducerFunction func1 = mock(ConsumerProducerFunction.class);
    // When
    final PassThroughFunctionContext<String, ConsumerProducerFunction> context = new PassThroughFunctionContext.Builder<String, ConsumerProducerFunction>().select(reference1, reference2).execute(func1).build();
    // Then
    assertEquals(2, context.getSelection().size());
    assertEquals(reference1, context.getSelection().get(0));
    assertEquals(reference2, context.getSelection().get(1));
    assertSame(func1, context.getFunction());
}
Also used : ConsumerProducerFunction(uk.gov.gchq.gaffer.function.ConsumerProducerFunction) Test(org.junit.Test)

Example 5 with ConsumerProducerFunction

use of uk.gov.gchq.gaffer.function.ConsumerProducerFunction in project Gaffer by gchq.

the class PassThroughFunctionContextTest method shouldThrowExceptionWhenBuildContextWhenSelectCalledTwice.

@Test
public void shouldThrowExceptionWhenBuildContextWhenSelectCalledTwice() {
    // Given
    final String reference1 = "reference 1";
    final String reference2 = "reference 2";
    final ConsumerProducerFunction func1 = mock(ConsumerProducerFunction.class);
    // When / Then
    try {
        new PassThroughFunctionContext.Builder<String, ConsumerProducerFunction>().select(reference1).execute(func1).select(reference2).build();
        fail("Exception expected");
    } catch (final IllegalStateException e) {
        assertNotNull(e);
    }
}
Also used : ConsumerProducerFunction(uk.gov.gchq.gaffer.function.ConsumerProducerFunction) Test(org.junit.Test)

Aggregations

ConsumerProducerFunction (uk.gov.gchq.gaffer.function.ConsumerProducerFunction)9 Test (org.junit.Test)7 IdentifierType (uk.gov.gchq.gaffer.data.element.IdentifierType)1