AbstractKogitoDMNService implements KogitoDMNService { Map<String, JSITItemDefinition> indexDefinitionsByName(final List<JSITItemDefinition> allDefinitions) { final HashMap<String, JSITItemDefinition> index = new HashMap<>(); for (int i = 0; i < allDefinitions.size(); i++) { final JSITItemDefinition value = Js.uncheckedCast(allDefinitions.get(i)); index.put(value.getName(), value); } return Collections.unmodifiableMap(index); }  @Override FactModelTuple getFactModelTuple(final JSITDefinitions jsitDefinitions); boolean isJSITInputData(JSITDRGElement jsitdrgElement); boolean isJSITDecision(JSITDRGElement jsitdrgElement); Map<QName, String> getOtherAttributesMap(JSITDMNElement jsitInputDataVariable); static final String URI_FEEL; static final String WRONG_DMN_MESSAGE; }
@Test public void testIndexDefinitionsByName() { final JSITItemDefinition definition1 = mock(JSITItemDefinition.class); final JSITItemDefinition definition2 = mock(JSITItemDefinition.class); final JSITItemDefinition definition3 = mock(JSITItemDefinition.class); final String name1 = "name1"; final String name2 = "name2"; final String name3 = "name3"; final List<JSITItemDefinition> list = Arrays.asList(definition1, definition2, definition3); when(definition1.getName()).thenReturn(name1); when(definition2.getName()).thenReturn(name2); when(definition3.getName()).thenReturn(name3); final Map<String, JSITItemDefinition> index = abstractKogitoDMNServiceSpy.indexDefinitionsByName(list); assertEquals(3, index.size()); assertTrue(index.containsKey(name1)); assertTrue(index.containsKey(name2)); assertTrue(index.containsKey(name3)); assertEquals(definition1, index.get(name1)); assertEquals(definition2, index.get(name2)); assertEquals(definition3, index.get(name3)); }
@Test(expected = UnsupportedOperationException.class) public void testIndexDefinitionsUnmodifiable() { final JSITItemDefinition definition1 = mock(JSITItemDefinition.class); final String name1 = "name1"; final List<JSITItemDefinition> list = Arrays.asList(definition1); when(definition1.getName()).thenReturn(name1); final Map<String, JSITItemDefinition> index = abstractKogitoDMNServiceSpy.indexDefinitionsByName(list); index.put("name2", mock(JSITItemDefinition.class)); }