Search in sources :

Example 6 with DMNModelWithMetadata

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));
}
Also used : DMNModelWithMetadata(org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata) Storage(org.kie.kogito.persistence.api.Storage) DMNModelMetadata(org.kie.kogito.trusty.storage.api.model.decision.DMNModelMetadata) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 7 with 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);
}
Also used : DMNModelWithMetadata(org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata) DMNModelMetadata(org.kie.kogito.trusty.storage.api.model.decision.DMNModelMetadata)

Example 8 with 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);
}
Also used : DMNModelWithMetadata(org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata)

Aggregations

DMNModelWithMetadata (org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata)8 Test (org.junit.jupiter.api.Test)6 DMNModelMetadata (org.kie.kogito.trusty.storage.api.model.decision.DMNModelMetadata)4 Storage (org.kie.kogito.persistence.api.Storage)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 QuarkusTest (io.quarkus.test.junit.QuarkusTest)1 StorageImplMock (org.kie.kogito.trusty.service.common.mocks.StorageImplMock)1 Decision (org.kie.kogito.trusty.storage.api.model.decision.Decision)1