Search in sources :

Example 6 with VersionedProcessor

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) ByteArrayOutputStream(java.io.ByteArrayOutputStream) VersionedProcessor(org.apache.nifi.registry.flow.VersionedProcessor) Test(org.junit.Test)

Example 7 with VersionedProcessor

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) VersionedProcessGroup(org.apache.nifi.registry.flow.VersionedProcessGroup) ByteArrayOutputStream(java.io.ByteArrayOutputStream) VersionedProcessor(org.apache.nifi.registry.flow.VersionedProcessor) Test(org.junit.Test)

Example 8 with VersionedProcessor

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;
}
Also used : VersionedProcessor(org.apache.nifi.registry.flow.VersionedProcessor)

Aggregations

VersionedProcessor (org.apache.nifi.registry.flow.VersionedProcessor)8 HashMap (java.util.HashMap)3 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 URL (java.net.URL)2 StandardCharsets (java.nio.charset.StandardCharsets)2 SecureRandom (java.security.SecureRandom)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 Optional (java.util.Optional)2 Set (java.util.Set)2 UUID (java.util.UUID)2