Search in sources :

Example 1 with GetVariables

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetVariables(uk.gov.gchq.gaffer.operation.impl.GetVariables) Test(org.junit.jupiter.api.Test)

Example 2 with GetVariables

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetVariables(uk.gov.gchq.gaffer.operation.impl.GetVariables) Test(org.junit.jupiter.api.Test)

Example 3 with GetVariables

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetVariables(uk.gov.gchq.gaffer.operation.impl.GetVariables) Test(org.junit.jupiter.api.Test)

Example 4 with GetVariables

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) HashMap(java.util.HashMap) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) HashMap(java.util.HashMap) GetVariables(uk.gov.gchq.gaffer.operation.impl.GetVariables) Test(org.junit.jupiter.api.Test)

Example 5 with GetVariables

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);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) HashMap(java.util.HashMap) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map) HashMap(java.util.HashMap) GetVariables(uk.gov.gchq.gaffer.operation.impl.GetVariables) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)5 GetVariables (uk.gov.gchq.gaffer.operation.impl.GetVariables)5 Context (uk.gov.gchq.gaffer.store.Context)5 ImmutableMap (com.google.common.collect.ImmutableMap)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2