AbstractKogitoDMNService implements KogitoDMNService { ClientDMNType getOrCreateDMNType(final Map<String, JSITItemDefinition> allDefinitions, final String requiredType, final String namespace, final Map<String, ClientDMNType> createdTypes) { if (createdTypes.containsKey(requiredType)) { return createdTypes.get(requiredType); } if (!allDefinitions.containsKey(requiredType)) { throw new IllegalStateException("Type '" + requiredType + "' not found."); } final JSITItemDefinition value = Js.uncheckedCast(allDefinitions.get(requiredType)); return createDMNType(allDefinitions, value, namespace, createdTypes); }  @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 testGetOrCreateDMNType() { final String namespace = "namespace"; final String typeOneName = "tTypeOne"; final String typeTwoName = "tTypeTwo"; final String typeThreeName = "tTypeThree"; final JSITItemDefinition definition1 = createJSITItemDefinitionMock(typeOneName); final JSITItemDefinition definition2 = createJSITItemDefinitionMock(typeTwoName); final JSITItemDefinition definition3 = createJSITItemDefinitionMock(typeThreeName); final Map<String, JSITItemDefinition> indexed = abstractKogitoDMNServiceSpy.indexDefinitionsByName(Arrays.asList(definition1, definition2, definition3)); final Map<String, ClientDMNType> createdTypes = new HashMap<>(); final ClientDMNType dmnTypeOne = mock(ClientDMNType.class); final ClientDMNType dmnTypeTwo = mock(ClientDMNType.class); final ClientDMNType dmnTypeThree = mock(ClientDMNType.class); doReturn(dmnTypeOne).when(abstractKogitoDMNServiceSpy).createDMNType(indexed, definition1, namespace, createdTypes); doReturn(dmnTypeTwo).when(abstractKogitoDMNServiceSpy).createDMNType(indexed, definition2, namespace, createdTypes); doReturn(dmnTypeThree).when(abstractKogitoDMNServiceSpy).createDMNType(indexed, definition3, namespace, createdTypes); final ClientDMNType actualDmnTypeOne = abstractKogitoDMNServiceSpy.getOrCreateDMNType(indexed, typeOneName, namespace, createdTypes); final ClientDMNType actualDmnTypeTwo = abstractKogitoDMNServiceSpy.getOrCreateDMNType(indexed, typeTwoName, namespace, createdTypes); final ClientDMNType actualDmnTypeThree = abstractKogitoDMNServiceSpy.getOrCreateDMNType(indexed, typeThreeName, namespace, createdTypes); assertEquals(dmnTypeOne, actualDmnTypeOne); assertEquals(dmnTypeTwo, actualDmnTypeTwo); assertEquals(dmnTypeThree, actualDmnTypeThree); }
@Test(expected = IllegalStateException.class) public void testGetOrCreateDMNTypeWhenTypeIsNotFound() { final String namespace = "namespace"; final Map<String, JSITItemDefinition> indexed = new HashMap<>(); final Map<String, ClientDMNType> createdTypes = new HashMap<>(); abstractKogitoDMNServiceSpy.getOrCreateDMNType(indexed, "unknownType", namespace, createdTypes); }