CircuitInterface implements Serializable { @Override public String toString() { StringBuilder sb = new StringBuilder(10 + ports.size() * 50); sb.append("ENTITY ").append(name).append(" IS"); if (!ports.isEmpty()) { sb.append(" PORT(\n"); for (Port p : ports) { sb.append("\t").append(p).append(";\n"); } sb.delete(sb.length() - 2, sb.length() - 1); sb.append(");"); } sb.append("\nEND ").append(name).append(";"); return sb.toString(); } CircuitInterface();  CircuitInterface(String name);  CircuitInterface(String name, Port port); String getName(); void setName(String name); boolean isName(String circuitName); void addAll(List<Port> collection); void add(Port port); Port getPort(String portName); List<Port> getPorts(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testToString() { ci.setName("ci_name"); toStringPrint(ci); assertEquals("ENTITY ci_name IS\nEND ci_name;", ci.toString()); Port port = new Port("a", PortDirection.IN); ci.add(port); toStringPrint(ci); assertEquals( "ENTITY ci_name IS PORT(\n\ta: IN STD_LOGIC\n);\nEND ci_name;", ci.toString()); port = new Port("f", PortDirection.OUT); ci.add(port); toStringPrint(ci); assertEquals( "ENTITY ci_name IS PORT(\n\ta: IN STD_LOGIC;\n\tf: OUT STD_LOGIC\n);\nEND ci_name;", ci.toString()); }