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