Search in sources :

Example 1 with IfScoreResolver

use of uk.gov.gchq.gaffer.store.operation.resolver.IfScoreResolver in project Gaffer by gchq.

the class ScoreOperationChainHandler method addDefaultScoreResolvers.

/**
 * Adds Gaffer's native {@link ScoreResolver} implementations to the list of available <code>ScoreResolver</code>s.
 * Any new implementations should be added to the map in this method, along with their respective class.
 *
 * @return a map of Operation class to ScoreResolver implementation
 */
private static Map<Class<? extends Operation>, ScoreResolver> addDefaultScoreResolvers() {
    final Map<Class<? extends Operation>, ScoreResolver> defaultResolvers = new HashMap<>();
    defaultResolvers.put(NamedOperation.class, new NamedOperationScoreResolver());
    defaultResolvers.put(If.class, new IfScoreResolver());
    defaultResolvers.put(While.class, new WhileScoreResolver());
    return Collections.unmodifiableMap(defaultResolvers);
}
Also used : NamedOperationScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.named.NamedOperationScoreResolver) DefaultScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.DefaultScoreResolver) ScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.ScoreResolver) WhileScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.WhileScoreResolver) IfScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.IfScoreResolver) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IfScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.IfScoreResolver) NamedOperationScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.named.NamedOperationScoreResolver) NamedOperation(uk.gov.gchq.gaffer.named.operation.NamedOperation) Operation(uk.gov.gchq.gaffer.operation.Operation) WhileScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.WhileScoreResolver)

Example 2 with IfScoreResolver

use of uk.gov.gchq.gaffer.store.operation.resolver.IfScoreResolver in project Gaffer by gchq.

the class ScoreOperationChainHandlerTest method shouldReAddDefaultScoreResolversWhenCallingSetMethod.

@Test
public void shouldReAddDefaultScoreResolversWhenCallingSetMethod() {
    // Given
    final ScoreOperationChainHandler handler = new ScoreOperationChainHandler();
    final Map<Class<? extends Operation>, ScoreResolver> defaultResolvers = ScoreOperationChainHandler.getDefaultScoreResolvers();
    final Map<Class<? extends Operation>, ScoreResolver> expectedMap = new HashMap<>();
    expectedMap.putAll(defaultResolvers);
    final Map<Class<? extends Operation>, ScoreResolver> inputMap = new HashMap<>();
    inputMap.put(GetElements.class, new DefaultScoreResolver(null));
    inputMap.put(GetAllElements.class, new DefaultScoreResolver(null));
    expectedMap.putAll(inputMap);
    // When
    handler.setScoreResolvers(inputMap);
    final Map<Class<? extends Operation>, ScoreResolver> results = handler.getScoreResolvers();
    // Then
    assertEquals(expectedMap.keySet(), results.keySet());
    assertTrue(results.get(NamedOperation.class) instanceof NamedOperationScoreResolver);
    assertTrue(results.get(If.class) instanceof IfScoreResolver);
    assertEquals(expectedMap.size(), results.size());
}
Also used : NamedOperationScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.named.NamedOperationScoreResolver) DefaultScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.DefaultScoreResolver) ScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.ScoreResolver) IfScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.IfScoreResolver) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IfScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.IfScoreResolver) NamedOperationScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.named.NamedOperationScoreResolver) NamedOperation(uk.gov.gchq.gaffer.named.operation.NamedOperation) Operation(uk.gov.gchq.gaffer.operation.Operation) DefaultScoreResolver(uk.gov.gchq.gaffer.store.operation.resolver.DefaultScoreResolver) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 NamedOperation (uk.gov.gchq.gaffer.named.operation.NamedOperation)2 Operation (uk.gov.gchq.gaffer.operation.Operation)2 DefaultScoreResolver (uk.gov.gchq.gaffer.store.operation.resolver.DefaultScoreResolver)2 IfScoreResolver (uk.gov.gchq.gaffer.store.operation.resolver.IfScoreResolver)2 ScoreResolver (uk.gov.gchq.gaffer.store.operation.resolver.ScoreResolver)2 NamedOperationScoreResolver (uk.gov.gchq.gaffer.store.operation.resolver.named.NamedOperationScoreResolver)2 Test (org.junit.jupiter.api.Test)1 WhileScoreResolver (uk.gov.gchq.gaffer.store.operation.resolver.WhileScoreResolver)1