use of org.kie.kogito.persistence.api.schema.SchemaType 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.SchemaType 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.SchemaType 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