use of uk.gov.gchq.gaffer.operation.impl.GetVariable in project Gaffer by gchq.
the class GetVariableHandlerTest method shouldNotThrowNPEWhenVariablesSet.
@Test
public void shouldNotThrowNPEWhenVariablesSet() throws OperationException {
// Given
final Context context = new Context(new User());
final GetVariableHandler handler = new GetVariableHandler();
final GetVariable op = new GetVariable.Builder().variableName(varName).build();
// When
final Object variableValueFromOp = handler.doOperation(op, context, store);
// Then
assertNull(variableValueFromOp);
}
use of uk.gov.gchq.gaffer.operation.impl.GetVariable in project Gaffer by gchq.
the class GetVariableHandlerTest method shouldReturnNullWhenVariableDoesntExist.
@Test
public void shouldReturnNullWhenVariableDoesntExist() throws OperationException {
// Given
final Context context = mock(Context.class);
final GetVariableHandler handler = new GetVariableHandler();
final GetVariable op = new GetVariable.Builder().variableName(varName).build();
given(context.getVariable(varName)).willReturn(null);
// When
final Object variableValueFromOp = handler.doOperation(op, context, store);
// Then
assertNull(variableValueFromOp);
}
use of uk.gov.gchq.gaffer.operation.impl.GetVariable in project Gaffer by gchq.
the class GetVariableHandlerTest method shouldThrowExceptionWhenVariableKeyIsNull.
@Test
public void shouldThrowExceptionWhenVariableKeyIsNull() throws OperationException {
// Given
final Context context = mock(Context.class);
final GetVariableHandler handler = new GetVariableHandler();
final GetVariable op = new GetVariable.Builder().variableName(null).build();
// When / Then
assertThatIllegalArgumentException().isThrownBy(() -> handler.doOperation(op, context, store)).withMessage("Variable name cannot be null");
}
use of uk.gov.gchq.gaffer.operation.impl.GetVariable in project Gaffer by gchq.
the class GetVariableHandlerTest method shouldGetVariableWhenExists.
@Test
public void shouldGetVariableWhenExists() throws OperationException {
// Given
final Context context = mock(Context.class);
final GetVariableHandler handler = new GetVariableHandler();
final GetVariable op = new GetVariable.Builder().variableName(varName).build();
given(context.getVariable(varName)).willReturn(varVal);
// When
final Object variableValueFromOp = handler.doOperation(op, context, store);
// Then
assertEquals(varVal, variableValueFromOp);
}
Aggregations