use of org.kie.kogito.persistence.api.schema.ProcessDescriptor in project kogito-apps by kiegroup.
the class ProtoSchemaManagerTest method onSchemaRegisteredEvent.
@Test
void onSchemaRegisteredEvent() {
String processId = "testProcessId";
String processType = "testProcessType";
ProcessDescriptor processDescriptor = new ProcessDescriptor(processId, processType);
String name = "testName";
String content = "testContent";
SchemaDescriptor schemaDescriptor = new SchemaDescriptor(name, content, emptyMap(), processDescriptor);
SchemaType schemaType = new SchemaType(ProtoSchemaAcceptor.PROTO_SCHEMA_TYPE);
SchemaRegisteredEvent event = new SchemaRegisteredEvent(schemaDescriptor, schemaType);
protoSchemaManager.onSchemaRegisteredEvent(event);
verify(protoSchemaAcceptor).accept(eq(schemaType));
verify(protobufCache).put(eq(name), eq(content));
verify(processIdModelCache).put(eq(processId), eq(processType));
verify(remoteCacheManagerAdmin).getOrCreateCache(eq(processId + "_domain"), any(BasicConfiguration.class));
verify(cacheManager).getDomainModelCacheName(processId);
verify(cacheTemplate).data("cache_name", processId + "_domain");
verify(templateInstance).data("indexed", emptySet());
}
use of org.kie.kogito.persistence.api.schema.ProcessDescriptor in project kogito-apps by kiegroup.
the class ProtoSchemaManagerTest method onSchemaRegisteredEventWithError.
@Test
void onSchemaRegisteredEventWithError() {
String processId = "testProcessId";
String processType = "testProcessType";
ProcessDescriptor processDescriptor = new ProcessDescriptor(processId, processType);
String name = "testName";
String content = "testContent";
SchemaDescriptor schemaDescriptor = new SchemaDescriptor(name, content, emptyMap(), processDescriptor);
SchemaType schemaType = new SchemaType(ProtoSchemaAcceptor.PROTO_SCHEMA_TYPE);
SchemaRegisteredEvent event = new SchemaRegisteredEvent(schemaDescriptor, schemaType);
when(protobufCache.containsKey(eq(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX))).thenReturn(true);
when(protobufCache.get(eq(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX))).thenReturn("testError");
assertThrows(SchemaRegistrationException.class, () -> protoSchemaManager.onSchemaRegisteredEvent(event));
verify(protoSchemaAcceptor).accept(eq(schemaType));
verify(protobufCache).put(eq(name), eq(content));
verify(processIdModelCache).put(eq(processId), eq(processType));
}
use of org.kie.kogito.persistence.api.schema.ProcessDescriptor in project kogito-apps by kiegroup.
the class ProcessIndexObserverIT method testOnProcessIndexEvent.
@Test
void testOnProcessIndexEvent() {
String processId = "testProcess";
String processType = "testProcessType";
ProcessDescriptor processDescriptor = new ProcessDescriptor(processId, processType);
ProcessIndexEvent processIndexEvent = new ProcessIndexEvent(processDescriptor);
processIndexObserver.onProcessIndexEvent(processIndexEvent);
Storage<String, String> processIdStorage = new MongoStorage<>(mongoClientManager.getCollection(PROCESS_ID_MODEL_STORAGE, ProcessIdEntity.class), String.class.getName(), new ProcessIdEntityMapper());
assertTrue(processIdStorage.containsKey(processId));
assertEquals(processType, processIdStorage.get(processId));
mockIndexCreateOrUpdateEventListener.assertFire("testProcess_domain", processType);
}
use of org.kie.kogito.persistence.api.schema.ProcessDescriptor in project kogito-apps by kiegroup.
the class ProtobufServiceTest method registerProtoBufferTypeSchemaRegistrationFailed.
@Test
void registerProtoBufferTypeSchemaRegistrationFailed() {
String testExceptionMessage = "test schema registration fail";
doThrow(new RuntimeException(testExceptionMessage)).when(schemaEvent).fire(any(SchemaRegisteredEvent.class));
String content = TestUtils.getTestFileContent();
String exceptionMessage = "";
try {
protobufService.registerProtoBufferType(content);
} catch (ProtobufValidationException e) {
exceptionMessage = e.getMessage();
}
assertEquals(testExceptionMessage, exceptionMessage);
verify(schemaEvent, times(1)).fire(new SchemaRegisteredEvent(new SchemaDescriptor(TestUtils.PROCESS_ID + ".proto", content, getValidEntityIndexDescriptors(true), new ProcessDescriptor(TestUtils.PROCESS_ID, TestUtils.PROCESS_TYPE)), SCHEMA_TYPE));
verify(domainModelEvent, never()).fire(any(FileDescriptorRegisteredEvent.class));
}
use of org.kie.kogito.persistence.api.schema.ProcessDescriptor in project kogito-apps by kiegroup.
the class IndexManagerIT method testOnSchemaRegisteredEvent.
@Test
void testOnSchemaRegisteredEvent() {
Map<String, EntityIndexDescriptor> indexes = new HashMap<>();
indexes.put("test", travelEntityIndexDescriptor);
indexManager.getCollectionIndexMapping().put("test", travelEntityIndexDescriptor.getName());
indexManager.onSchemaRegisteredEvent(new SchemaRegisteredEvent(new SchemaDescriptor("test", "test", indexes, new ProcessDescriptor("test", travelEntityIndexDescriptor.getName())), new SchemaType("test")));
MongoCollection<Document> testCollection = indexManager.getCollection("test");
collections.add(testCollection);
Set<String> testIndexes = StreamSupport.stream(testCollection.listIndexes().spliterator(), false).map(document -> document.getString(INDEX_NAME_FIELD)).filter(name -> !DEFAULT_INDEX.equals(name)).collect(toSet());
assertEquals(getTestIndexNames(), testIndexes);
mockProcessIndexEventListener.assertFire("test", travelEntityIndexDescriptor.getName());
}
Aggregations