use of uk.gov.gchq.gaffer.operation.impl.GetVariables in project Gaffer by gchq.
the class GetVariablesHandlerTest method shouldReturnNothingWhenGetVariablesKeysAreNull.
@Test
public void shouldReturnNothingWhenGetVariablesKeysAreNull() throws OperationException {
// Given
final Context context = mock(Context.class);
final GetVariables op = new GetVariables.Builder().variableNames(Arrays.asList(null, null)).build();
// When
final GetVariablesHandler handler = new GetVariablesHandler();
Map<String, Object> resultMap = handler.doOperation(op, context, store);
// Then
assertEquals(new HashMap<>(), resultMap);
}
use of uk.gov.gchq.gaffer.operation.impl.GetVariables in project Gaffer by gchq.
the class GetVariablesHandlerTest method shouldReturnEmptyMapWhenGetVariablesIsNull.
@Test
public void shouldReturnEmptyMapWhenGetVariablesIsNull() throws OperationException {
// Given
final Context context = mock(Context.class);
final GetVariables op = new GetVariables.Builder().variableNames(null).build();
final GetVariablesHandler handler = new GetVariablesHandler();
// When
final Map<String, Object> resultMap = handler.doOperation(op, context, store);
// Then
assertEquals(new HashMap<>(), resultMap);
}
use of uk.gov.gchq.gaffer.operation.impl.GetVariables in project Gaffer by gchq.
the class GetVariablesHandlerTest method shouldGetAllVariableValuesWhenAllPresent.
@Test
public void shouldGetAllVariableValuesWhenAllPresent() throws OperationException {
final Context context = mock(Context.class);
// Given
given(context.getVariable(key1)).willReturn(val1);
given(context.getVariable(key2)).willReturn(val2);
given(context.getVariable(key3)).willReturn(val3);
final GetVariables op = new GetVariables.Builder().variableNames(Arrays.asList(key1, key2, key3)).build();
final GetVariablesHandler handler = new GetVariablesHandler();
// When
Map<String, Object> resultMap = handler.doOperation(op, context, store);
// Then
assertEquals(ImmutableMap.of(key1, val1, key2, val2, key3, val3), resultMap);
}
use of uk.gov.gchq.gaffer.operation.impl.GetVariables in project Gaffer by gchq.
the class GetVariablesHandlerTest method shouldReturnPartiallyFilledMapWhenSomeValuesPresent.
@Test
public void shouldReturnPartiallyFilledMapWhenSomeValuesPresent() throws OperationException {
// Given
final Context context = mock(Context.class);
given(context.getVariable(key1)).willReturn(val1);
given(context.getVariable(key2)).willReturn(null);
given(context.getVariable(key3)).willReturn(val3);
final GetVariables op = new GetVariables.Builder().variableNames(Arrays.asList(key1, key2, key3)).build();
final GetVariablesHandler handler = new GetVariablesHandler();
// When
final Map<String, Object> resultMap = handler.doOperation(op, context, store);
// Then
final Map expected = new HashMap<>();
expected.put(key1, val1);
expected.put(key2, null);
expected.put(key3, val3);
assertEquals(expected, resultMap);
}
use of uk.gov.gchq.gaffer.operation.impl.GetVariables in project Gaffer by gchq.
the class GetVariablesHandlerTest method shouldReturnEmptyMapWhenNoValuesPresent.
@Test
public void shouldReturnEmptyMapWhenNoValuesPresent() throws OperationException {
// Given
final Context context = mock(Context.class);
given(context.getVariable(key1)).willReturn(null);
given(context.getVariable(key2)).willReturn(null);
given(context.getVariable(key3)).willReturn(null);
final GetVariables op = new GetVariables.Builder().variableNames(Arrays.asList(key1, key2, key3)).build();
final GetVariablesHandler handler = new GetVariablesHandler();
// When
Map<String, Object> resultMap = handler.doOperation(op, context, store);
// Then
final Map expected = new HashMap<>();
expected.put(key1, null);
expected.put(key2, null);
expected.put(key3, null);
assertEquals(expected, resultMap);
}
Aggregations