本文整理匯總了Java中org.manifold.compiler.middle.Schematic.getConnection方法的典型用法代碼示例。如果您正苦於以下問題:Java Schematic.getConnection方法的具體用法?Java Schematic.getConnection怎麽用?Java Schematic.getConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.manifold.compiler.middle.Schematic
的用法示例。
在下文中一共展示了Schematic.getConnection方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testModifyConnectionAttribute
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test
public void testModifyConnectionAttribute()
throws SchematicException {
// Modify the "xyzzy" attribute on connection "wire" to be False instead of
// True.
ConnectionValue cOriginal = originalSchematic.getConnection(
CONNECTION_NAME);
assertTrue("precondition failed",
cOriginal.getAttribute(CONN_ATTR_XYZZY).equals(
BooleanValue.getInstance(false)));
BackAnnotationBuilder builder =
new BackAnnotationBuilder(originalSchematic);
builder.annotateConnectionAttribute(CONNECTION_NAME, CONN_ATTR_XYZZY,
BooleanValue.getInstance(true));
Schematic modifiedSchematic = builder.build();
ConnectionValue cModified = modifiedSchematic.getConnection(
CONNECTION_NAME);
assertTrue("back-annotation failed",
cModified.getAttribute(CONN_ATTR_XYZZY).equals(
BooleanValue.getInstance(true)));
}
示例2: testModifyConnectionAttribute_PreservesOthers
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test
public void testModifyConnectionAttribute_PreservesOthers()
throws SchematicException {
// Check that modifying one connection attribute doesn't modify any others.
ConnectionValue cOriginal = originalSchematic.getConnection(
CONNECTION_NAME);
assertTrue("precondition failed",
cOriginal.getAttribute(CONN_ATTR_ASDF).equals(
BooleanValue.getInstance(false)));
BackAnnotationBuilder builder =
new BackAnnotationBuilder(originalSchematic);
builder.annotateConnectionAttribute(CONNECTION_NAME, CONN_ATTR_XYZZY,
BooleanValue.getInstance(true));
Schematic modifiedSchematic = builder.build();
ConnectionValue cModified = modifiedSchematic.getConnection(
CONNECTION_NAME);
assertTrue("back-annotation smashed unmodified connection attribute",
cModified.getAttribute(CONN_ATTR_ASDF).equals(
BooleanValue.getInstance(false)));
}
示例3: testCopyConstraint_RecreatedConnection
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test
public void testCopyConstraint_RecreatedConnection()
throws SchematicException {
// Check that a constraint referencing a connection actually refers
// to the correct connection in the backannotated copy.
BackAnnotationBuilder builder =
new BackAnnotationBuilder(originalSchematic);
Schematic modifiedSchematic = builder.build();
ConnectionValue expectedConn = modifiedSchematic
.getConnection(CONNECTION_NAME);
ConstraintValue cxt = modifiedSchematic.getConstraint("c1");
ConnectionValue actualConn = (ConnectionValue)
cxt.getAttribute("conn_reference");
assertEquals(expectedConn, actualConn);
}
示例4: testGetConnection
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test
public void testGetConnection() throws SchematicException {
Schematic sch = new Schematic("test");
ConnectionTypeValue connType = null;
NodeValue node1 = null, node2 = null;
Map<String, Value> connAttrs = null;
String connName = "conn1";
// create a test port type
String portTypeName = "TestPort";
PortTypeValue portType = new PortTypeValue(
BooleanTypeValue.getInstance(), portAttributes);
sch.addPortType(portTypeName, portType);
// create a test node type
String nodeTypeName = "TestNode";
Map<String, PortTypeValue> ports = new HashMap<>();
ports.put("p", portType);
NodeTypeValue nodeType = new NodeTypeValue(attributes, ports);
sch.addNodeType(nodeTypeName, nodeType);
// create two nodes based on this type
Map<String, Value> nodeAttrs = new HashMap<>();
Map<String, Map<String, Value>> nodePortAttrs = new HashMap<>();
nodePortAttrs.put("p", new HashMap<>());
node1 = new NodeValue(nodeType, nodeAttrs, nodePortAttrs);
sch.addNode("node1", node1);
node2 = new NodeValue(nodeType, nodeAttrs, nodePortAttrs);
sch.addNode("node2", node2);
// create the first connection
connAttrs = new HashMap<>();
ConnectionValue conn1 = new ConnectionValue(
node1.getPort("p"), node2.getPort("p"), connAttrs);
sch.addConnection(connName, conn1);
ConnectionValue actual = sch.getConnection(connName);
assertEquals(conn1, actual);
}
示例5: testPassthrough
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test
public void testPassthrough() throws SchematicException {
// If we don't make any annotations, the builder should give us back
// a schematic whose nodes, ports, connections, and constraints
// have the same attributes as the one that we started with.
BackAnnotationBuilder builder =
new BackAnnotationBuilder(originalSchematic);
Schematic modifiedSchematic = builder.build();
NodeValue inNodeOriginal = originalSchematic.getNode("nIN");
NodeValue inNodeModified = modifiedSchematic.getNode("nIN");
assertTrue(inNodeOriginal.getAttributes().
equals(inNodeModified.getAttributes()));
PortValue inPortOriginal = inNodeOriginal.getPort(IN_PORT_NAME);
PortValue inPortModified = inNodeModified.getPort(IN_PORT_NAME);
assertTrue(inPortOriginal.getAttributes().
equals(inPortModified.getAttributes()));
ConnectionValue inConnOriginal = originalSchematic.
getConnection(CONNECTION_NAME);
ConnectionValue inConnModified = modifiedSchematic.
getConnection(CONNECTION_NAME);
assertTrue(inConnOriginal.getAttributes().
equals(inConnModified.getAttributes()));
}
示例6: testDeserialize
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test
public void testDeserialize() throws IOException,
UndeclaredIdentifierException, UndeclaredAttributeException {
final String IN_NODE_NAME = "in_node";
final String OUT_NODE_NAME = "out_node";
final String DIGITAL_IN_PORT_NAME = "digital_in";
final String DIGITAL_OUT_PORT_NAME = "digital_out";
URL url = Resources
.getResource("org/manifold/compiler/serialization/data/"
+ "deserialization-types-test.json");
JsonObject json = new JsonParser().parse(
Resources.toString(url, Charsets.UTF_8)).getAsJsonObject();
Schematic sch = new SchematicDeserializer().deserialize(json);
Map<String, PortTypeValue> outNodePorts = sch.getNodeType(OUT_NODE_NAME)
.getPorts();
Map<String, PortTypeValue> inNodePorts = sch.getNodeType(IN_NODE_NAME)
.getPorts();
PortTypeValue digitalIn = sch.getPortType(DIGITAL_IN_PORT_NAME);
PortTypeValue digitalOut = sch.getPortType(DIGITAL_OUT_PORT_NAME);
assertEquals(TEST_SCHEMATIC_NAME, sch.getName());
assertTrue(sch.getUserDefinedType("Flag")
.isSubtypeOf(BooleanTypeValue.getInstance()));
assertEquals(digitalIn, inNodePorts.get("in1"));
assertEquals(digitalIn, inNodePorts.get("in2"));
assertEquals(digitalOut, outNodePorts.get("out2"));
assertEquals(digitalOut, outNodePorts.get("out2"));
NodeValue andNode = sch.getNode("and_node");
NodeValue andNode2 = sch.getNode("and_node2");
assertEquals(sch.getNodeType("and"), andNode.getType());
assertEquals(andNode.getType(), andNode2.getType());
assertEquals(digitalIn, andNode.getPort("in1").getType());
assertFalse(((BooleanValue) andNode.getAttribute("is_awesome"))
.toBoolean());
assertTrue(((BooleanValue) andNode2.getAttribute("is_awesome"))
.toBoolean());
ConnectionValue conVal = sch.getConnection("con1");
assertEquals(andNode.getPort("out1"), conVal.getFrom());
assertEquals(andNode2.getPort("in2"), conVal.getTo());
}
示例7: testDeserializeInferredAttributes
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test
public void testDeserializeInferredAttributes() throws IOException,
UndeclaredIdentifierException, UndeclaredAttributeException {
final String IN_NODE_NAME = "in_node";
final String OUT_NODE_NAME = "out_node";
final String DIGITAL_IN_PORT_NAME = "digital_in";
final String DIGITAL_OUT_PORT_NAME = "digital_out";
URL url = Resources
.getResource("org/manifold/compiler/serialization/data/"
+ "deserialization-inferred-attributes-test.json");
JsonObject json = new JsonParser().parse(
Resources.toString(url, Charsets.UTF_8)).getAsJsonObject();
Schematic sch = new SchematicDeserializer().deserialize(json);
Map<String, PortTypeValue> outNodePorts = sch.getNodeType(OUT_NODE_NAME)
.getPorts();
Map<String, PortTypeValue> inNodePorts = sch.getNodeType(IN_NODE_NAME)
.getPorts();
PortTypeValue digitalIn = sch.getPortType(DIGITAL_IN_PORT_NAME);
PortTypeValue digitalOut = sch.getPortType(DIGITAL_OUT_PORT_NAME);
assertEquals(TEST_SCHEMATIC_NAME, sch.getName());
assertEquals(digitalIn, inNodePorts.get("in1"));
assertEquals(digitalIn, inNodePorts.get("in2"));
assertEquals(digitalOut, outNodePorts.get("out2"));
assertEquals(digitalOut, outNodePorts.get("out2"));
NodeValue andNode = sch.getNode("and_node");
NodeValue andNode2 = sch.getNode("and_node2");
assertEquals(sch.getNodeType("and"), andNode.getType());
assertEquals(andNode.getType(), andNode2.getType());
assertEquals(digitalIn, andNode.getPort("in1").getType());
assertEquals(BooleanValue.getInstance(false),
((InferredValue) andNode.getAttribute("is_awesome")).get());
assertEquals(null,
((InferredValue) andNode2.getAttribute("is_awesome")).get());
ConnectionValue conVal = sch.getConnection("con1");
assertEquals(andNode.getPort("out1"), conVal.getFrom());
assertEquals(andNode2.getPort("in2"), conVal.getTo());
InferredValue foom = (InferredValue) andNode.getPort("out1")
.getAttributes().get("foom");
InferredValue foom2 = (InferredValue) andNode2.getPort("out1")
.getAttributes().get("foom");
assertEquals(null, foom.get());
assertEquals(BooleanValue.getInstance(true), foom2.get());
assertEquals(sch.getUserDefinedType("Bool"),
((InferredTypeValue) foom.getType()).getInferredType());
}
示例8: testGetConnection_Undeclared_ThrowsException
import org.manifold.compiler.middle.Schematic; //導入方法依賴的package包/類
@Test(expected = UndeclaredIdentifierException.class)
public void testGetConnection_Undeclared_ThrowsException()
throws SchematicException {
Schematic sch = new Schematic("test");
ConnectionValue cv = sch.getConnection("bogus");
}