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