use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata in project kogito-apps by kiegroup.
the class ExecutionsApiV1IT method givenARequestWithExistingModelWhenModelEndpointIsCalledThenTheModelIsReturned.
@Test
void givenARequestWithExistingModelWhenModelEndpointIsCalledThenTheModelIsReturned() {
DMNModelWithMetadata dmnModelWithMetadata = new DMNModelWithMetadata("groupId", "artifactId", "modelVersion", "dmnVersion", "name", "namespace", "definition");
final Decision decision = mock(Decision.class);
when(decision.getExecutedModelName()).thenReturn("name");
when(decision.getExecutedModelNamespace()).thenReturn("namespace");
when(executionService.getDecisionById(anyString())).thenReturn(decision);
when(executionService.getModelById(any(DMNModelMetadata.class), eq(DMNModelWithMetadata.class))).thenReturn(dmnModelWithMetadata);
DMNModelWithMetadata response = given().contentType(ContentType.TEXT).when().get("/executions/123/model").as(DMNModelWithMetadata.class);
assertEquals(dmnModelWithMetadata.getModel(), response.getModel());
assertEquals(dmnModelWithMetadata.getGroupId(), response.getGroupId());
assertEquals(dmnModelWithMetadata.getNamespace(), response.getNamespace());
assertEquals(dmnModelWithMetadata.getName(), response.getName());
assertEquals(dmnModelWithMetadata.getArtifactId(), response.getArtifactId());
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata in project kogito-apps by kiegroup.
the class AbstractModelEventConsumerIT method testCorrectCloudEvent.
@Test
void testCorrectCloudEvent() {
kafkaClient.produce(TrustyServiceTestUtils.buildCloudEventJsonString(TrustyServiceTestUtils.buildCorrectModelEvent()), KafkaConstants.KOGITO_TRACING_MODEL_TOPIC);
await().atMost(5, SECONDS).untilAsserted(() -> assertDoesNotThrow(() -> trustyService.getModelById(TrustyServiceTestUtils.getModelIdentifier(), DMNModelWithMetadata.class)));
DMNModelWithMetadata storedDefinition = trustyService.getModelById(TrustyServiceTestUtils.getModelIdentifier(), DMNModelWithMetadata.class);
assertNotNull(storedDefinition);
assertEquals("definition", storedDefinition.getModel());
assertEquals("name", storedDefinition.getName());
assertEquals("namespace", storedDefinition.getNamespace());
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata in project kogito-apps by kiegroup.
the class TrustyServiceTest method givenAModelWhenAModelIsStoredAndRetrievedByIdThenTheOriginalObjectIsReturned.
@Test
@SuppressWarnings("unchecked")
void givenAModelWhenAModelIsStoredAndRetrievedByIdThenTheOriginalObjectIsReturned() {
String model = TEST_MODEL;
Storage storageMock = new StorageImplMock(String.class);
when(trustyStorageServiceMock.getModelStorage(DMNModelWithMetadata.class)).thenReturn(storageMock);
DMNModelWithMetadata dmnModelWithMetadata = buildDmnModel(model);
DMNModelMetadata modelIdentifier = dmnModelWithMetadata.getModelMetaData();
trustyService.storeModel(buildDmnModel(model));
DMNModelWithMetadata result = trustyService.getModelById(modelIdentifier, DMNModelWithMetadata.class);
assertEquals(model, result.getModel());
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata in project kogito-apps by kiegroup.
the class AbstractTrustyServiceIT method givenAModelWhenGetModelByIdIsCalledThenTheModelIsReturned.
@Test
public void givenAModelWhenGetModelByIdIsCalledThenTheModelIsReturned() {
String model = "definition";
storeModel(model);
DMNModelWithMetadata result = getModel();
Assertions.assertEquals(model, result.getModel());
}
use of org.kie.kogito.trusty.storage.api.model.decision.DMNModelWithMetadata in project kogito-apps by kiegroup.
the class DMNModelWithMetadataMarshallerTest method testWriteAndRead.
@Test
public void testWriteAndRead() throws IOException {
DMNModelWithMetadata dmnModelWithMetadata = new DMNModelWithMetadata("groupId", "artifactId", "version", "dmnVersion", "name", "namespace", "XML_MODEL");
DMNModelWithMetadataMarshaller marshaller = new DMNModelWithMetadataMarshaller(new ObjectMapper());
marshaller.writeTo(writer, dmnModelWithMetadata);
DMNModelWithMetadata retrieved = marshaller.readFrom(reader);
Assertions.assertEquals(dmnModelWithMetadata.getGroupId(), retrieved.getGroupId());
Assertions.assertEquals(dmnModelWithMetadata.getArtifactId(), retrieved.getArtifactId());
Assertions.assertEquals(dmnModelWithMetadata.getModelVersion(), retrieved.getModelVersion());
Assertions.assertEquals(dmnModelWithMetadata.getDmnVersion(), retrieved.getDmnVersion());
Assertions.assertEquals(dmnModelWithMetadata.getModelMetaData().getName(), retrieved.getName());
Assertions.assertEquals(dmnModelWithMetadata.getModelMetaData().getNamespace(), retrieved.getNamespace());
Assertions.assertEquals(dmnModelWithMetadata.getModel(), retrieved.getModel());
}
Aggregations