use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata in project kogito-apps by kiegroup.
the class TrustyServiceTest method givenAModelWhenStoreModelIsCalledMoreThanOnceForSameModelThenExceptionIsThrown.
@Test
@SuppressWarnings("unchecked")
void givenAModelWhenStoreModelIsCalledMoreThanOnceForSameModelThenExceptionIsThrown() {
String model = TEST_MODEL;
Storage storageMock = mock(Storage.class);
DMNModelWithMetadata dmnModelWithMetadata = buildDmnModel(model);
DMNModelMetadata modelIdentifier = dmnModelWithMetadata.getModelMetaData();
when(storageMock.containsKey(modelIdentifier.getIdentifier())).thenReturn(true);
when(storageMock.put(any(Object.class), any(Object.class))).thenReturn(model);
when(trustyStorageServiceMock.getModelStorage(DMNModelWithMetadata.class)).thenReturn(storageMock);
assertThrows(IllegalArgumentException.class, () -> trustyService.storeModel(dmnModelWithMetadata));
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata in project kogito-apps by kiegroup.
the class ModelEventConsumer method internalHandleDecisionModelEvent.
private void internalHandleDecisionModelEvent(DecisionModelEvent decisionModelEvent) {
DMNModelMetadata identifier = new DMNModelMetadata(decisionModelEvent.getGav().getGroupId(), decisionModelEvent.getGav().getArtifactId(), decisionModelEvent.getGav().getVersion(), decisionModelEvent.getModelMetadata().getSpecVersion(), decisionModelEvent.getName(), decisionModelEvent.getNamespace());
DMNModelWithMetadata dmnModelWithMetadata = new DMNModelWithMetadata(identifier, decisionModelEvent.getDefinition());
service.storeModel(dmnModelWithMetadata);
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata in project kogito-apps by kiegroup.
the class AbstractTrustyServiceIT method storeModel.
private void storeModel(String model) {
DMNModelWithMetadata dmnModelWithMetadata = new DMNModelWithMetadata("groupId", "artifactId", "modelVersion", "dmnVersion", "name", "namespace", model);
trustyService.storeModel(dmnModelWithMetadata);
}
Aggregations