public void testSpiCreation() throws GraphException { Graph graph = new Graph("chain1"); Node node1 = new Node("node1", "Op1"); graph.addNode(node1); GraphContext graphContext = new GraphContext(graph); NodeContext nodeContext = graphContext.getNodeContext(node1); assertEquals("Op1", graph.getNode("node1").getOperatorName()); assertEquals("org.esa.beam.framework.gpf.TestOps$Op1", nodeContext.getOperator().getClass().getName()); }
public void testTargetProductCreation() throws GraphException { Graph graph = new Graph("chain1"); Node node1 = new Node("node1", "Op1"); graph.addNode(node1); GraphContext graphContext = new GraphContext(graph); Product[] outputProducts = graphContext.getOutputProducts(); assertNotNull(outputProducts); assertEquals(1, outputProducts.length); assertNotNull(outputProducts[0]); }
public void testAnnotationsProcessed() throws Exception { Graph graph = new Graph("graph"); Node node1 = new Node("node1", "Op1"); Node node2 = new Node("node2", "Op2"); Node node3 = new Node("node3", "Op3"); node2.addSource(new NodeSource("input", "node1")); node3.addSource(new NodeSource("input1", "node1")); node3.addSource(new NodeSource("input2", "node2")); graph.addNode(node1); graph.addNode(node2); graph.addNode(node3); GraphContext graphContext = new GraphContext(graph); NodeContext nodeContext2 = graphContext.getNodeContext(node2); NodeContext nodeContext3 = graphContext.getNodeContext(node3); TestOps.Op2 op2 = ((TestOps.Op2) nodeContext2.getOperator()); TestOps.Op3 op3 = ((TestOps.Op3) nodeContext3.getOperator()); assertNotNull(op2.input); assertSame(nodeContext2.getSourceProduct("input"), op2.input); assertNotNull(op3.input1); assertNotNull(op3.input2); assertSame(nodeContext3.getSourceProduct("input1"), op3.input1); assertSame(nodeContext3.getSourceProduct("input2"), op3.input2); assertNotNull(op3.inputs); assertEquals(0, op3.inputs.length); assertEquals(false, op3.ignoreSign); // has NO default value assertEquals("NN", op3.interpolMethod); // has default value assertEquals(1.5, op3.factor); // has default value }
public void testSourceToNodeResolving() throws GraphException { Graph graph = new Graph("chain1"); Node node1 = new Node("node1", "org.esa.beam.framework.gpf.TestOps$Op1$Spi"); Node node2 = new Node("node2", "org.esa.beam.framework.gpf.TestOps$Op2$Spi"); node2.addSource(new NodeSource("input", "node1")); Node node3 = new Node("node3", "org.esa.beam.framework.gpf.TestOps$Op3$Spi"); node3.addSource(new NodeSource("input1", "node1")); node3.addSource(new NodeSource("input2", "node2")); graph.addNode(node1); graph.addNode(node2); graph.addNode(node3); GraphContext graphContext = new GraphContext(graph); assertEquals(node2.getSource(0).getSourceNode(), node1); assertEquals(node3.getSource(0).getSourceNode(), node1); assertEquals(node3.getSource(1).getSourceNode(), node2); assertFalse(graphContext.getNodeContext(node1).isOutput()); assertFalse(graphContext.getNodeContext(node2).isOutput()); assertTrue(graphContext.getNodeContext(node3).isOutput()); }