use of org.infinispan.protostream.descriptors.FileDescriptor in project kogito-apps by kiegroup.
the class ProtoDomainModelProducerTest method onFileDescriptorRegistered.
@Test
void onFileDescriptorRegistered() {
FileDescriptor fileDescriptor = getTestFileDescriptor();
FileDescriptorRegisteredEvent event = new FileDescriptorRegisteredEvent(fileDescriptor);
protoDomainModelProducer.onFileDescriptorRegistered(event);
verify(domainEvent).fire(eq(new DomainModelRegisteredEvent(TestUtils.PROCESS_ID, TestUtils.DOMAIN_DESCRIPTOR, TestUtils.ADDITIONAL_DESCRIPTORS)));
}
use of org.infinispan.protostream.descriptors.FileDescriptor in project kogito-apps by kiegroup.
the class ProtoIndexParserTest method testCreateEntityIndexeDescriptors.
@Test
void testCreateEntityIndexeDescriptors() {
FileDescriptor fileDescriptor = createFileDescriptor();
Map<String, EntityIndexDescriptor> entityIndexes = createFileDescriptor().getMessageTypes().stream().map(t -> t.<EntityIndexDescriptor>getProcessedAnnotation(INDEXED_ANNOTATION)).filter(Objects::nonNull).collect(toMap(EntityIndexDescriptor::getName, Function.identity()));
Map<String, EntityIndexDescriptor> indexDescriptor = createEntityIndexDescriptors(fileDescriptor, entityIndexes);
assertEquals(getValidEntityIndexDescriptors(true), indexDescriptor);
}
use of org.infinispan.protostream.descriptors.FileDescriptor in project protostream by infinispan.
the class SerializationContextImpl method unregisterFileDescriptorTypes.
@GuardedBy("descriptorLock")
private void unregisterFileDescriptorTypes(FileDescriptor fileDescriptor) {
if (fileDescriptor.isResolved()) {
for (GenericDescriptor d : fileDescriptor.getTypes().values()) {
Integer typeId = d.getTypeId();
if (typeId != null) {
typeIds.remove(typeId);
}
if (d instanceof EnumDescriptor) {
for (EnumValueDescriptor ev : ((EnumDescriptor) d).getValues()) {
enumValueDescriptors.remove(ev.getScopedName());
}
}
}
genericDescriptors.keySet().removeAll(fileDescriptor.getTypes().keySet());
fileDescriptor.markUnresolved();
}
for (FileDescriptor fd : fileDescriptor.getDependants().values()) {
unregisterFileDescriptorTypes(fd);
}
}
use of org.infinispan.protostream.descriptors.FileDescriptor in project protostream by infinispan.
the class SerializationContextImpl method unregisterProtoFiles.
@Override
public void unregisterProtoFiles(Set<String> fileNames) {
log.debugf("Unregistering proto files : %s", fileNames);
long stamp = descriptorLock.writeLock();
try {
for (String fileName : fileNames) {
FileDescriptor fileDescriptor = fileDescriptors.remove(fileName);
if (fileDescriptor != null) {
unregisterFileDescriptorTypes(fileDescriptor);
} else {
throw new IllegalArgumentException("File " + fileName + " does not exist");
}
}
} finally {
descriptorLock.unlockWrite(stamp);
}
}
use of org.infinispan.protostream.descriptors.FileDescriptor in project protostream by infinispan.
the class SquareProtoParser method reportParsingError.
/**
* Report the error to the callback if any, or just throw it otherwise.
*/
private void reportParsingError(FileDescriptorSource fileDescriptorSource, Map<String, FileDescriptor> fileDescriptorMap, String fileName, DescriptorParserException dpe) {
if (fileDescriptorSource.getProgressCallback() == null) {
// fail fast
throw dpe;
}
// create an empty FileDescriptor that has just a name and a parsing error status
FileDescriptor stub = new FileDescriptor.Builder().withName(fileName).withParsingException(dpe).build();
stub.setConfiguration(configuration);
fileDescriptorMap.put(fileName, stub);
fileDescriptorSource.getProgressCallback().handleError(fileName, dpe);
}
Aggregations