use of org.apache.nifi.registry.flow.VersionedProcessor in project nifi-registry by apache.
the class TestVersionedProcessGroupSerializer method testSerializeDeserializeFlowSnapshot.
@Test
public void testSerializeDeserializeFlowSnapshot() throws SerializationException {
final Serializer<VersionedProcessGroup> serializer = new VersionedProcessGroupSerializer();
final VersionedProcessGroup processGroup1 = new VersionedProcessGroup();
processGroup1.setIdentifier("pg1");
processGroup1.setName("My Process Group");
final VersionedProcessor processor1 = new VersionedProcessor();
processor1.setIdentifier("processor1");
processor1.setName("My Processor 1");
// make sure nested objects are serialized/deserialized
processGroup1.getProcessors().add(processor1);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
serializer.serialize(processGroup1, out);
final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
final VersionedProcessGroup deserializedProcessGroup1 = serializer.deserialize(in);
Assert.assertEquals(processGroup1.getIdentifier(), deserializedProcessGroup1.getIdentifier());
Assert.assertEquals(processGroup1.getName(), deserializedProcessGroup1.getName());
Assert.assertEquals(1, deserializedProcessGroup1.getProcessors().size());
final VersionedProcessor deserializedProcessor1 = deserializedProcessGroup1.getProcessors().iterator().next();
Assert.assertEquals(processor1.getIdentifier(), deserializedProcessor1.getIdentifier());
Assert.assertEquals(processor1.getName(), deserializedProcessor1.getName());
}
use of org.apache.nifi.registry.flow.VersionedProcessor in project nifi-registry by apache.
the class TestJAXBVersionedProcessGroupSerializer method testSerializeDeserializeFlowSnapshot.
@Test
public void testSerializeDeserializeFlowSnapshot() throws SerializationException {
final Serializer<VersionedProcessGroup> serializer = new JAXBVersionedProcessGroupSerializer();
final VersionedProcessGroup processGroup1 = new VersionedProcessGroup();
processGroup1.setIdentifier("pg1");
processGroup1.setName("My Process Group");
final VersionedProcessor processor1 = new VersionedProcessor();
processor1.setIdentifier("processor1");
processor1.setName("My Processor 1");
// make sure nested objects are serialized/deserialized
processGroup1.getProcessors().add(processor1);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
serializer.serialize(processGroup1, out);
final String snapshotStr = new String(out.toByteArray(), StandardCharsets.UTF_8);
// System.out.println(snapshotStr);
final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
final VersionedProcessGroup deserializedProcessGroup1 = serializer.deserialize(in);
Assert.assertEquals(processGroup1.getIdentifier(), deserializedProcessGroup1.getIdentifier());
Assert.assertEquals(processGroup1.getName(), deserializedProcessGroup1.getName());
Assert.assertEquals(1, deserializedProcessGroup1.getProcessors().size());
final VersionedProcessor deserializedProcessor1 = deserializedProcessGroup1.getProcessors().iterator().next();
Assert.assertEquals(processor1.getIdentifier(), deserializedProcessor1.getIdentifier());
Assert.assertEquals(processor1.getName(), deserializedProcessor1.getName());
}
use of org.apache.nifi.registry.flow.VersionedProcessor in project nifi-registry by apache.
the class TestRegistryService method createVersionedProcessor.
private VersionedProcessor createVersionedProcessor(String name) {
VersionedProcessor processor = new VersionedProcessor();
processor.setName(name);
processor.setIdentifier(name);
processor.setProperties(new HashMap<>());
return processor;
}
Aggregations