ImplicitToExplicit extends AbstractFunction<Graph,Graph> { static Edge toExplicitEdge(final Graph g, final Edge e) { final int u = e.either(), v = e.other(u); if (e.bond() == Bond.IMPLICIT) { return new Edge(u, v, type(g.atom(u), g.atom(v))); } return e; }  Graph apply(final Graph g);  }
@Test public void toExplicitEdge_NonImplicitIdentity() { Graph g = new Graph(0); for (Bond b : Bond.values()) { if (b != IMPLICIT) { Edge e = new Edge(0, 1, SINGLE); Assert.assertThat(ImplicitToExplicit .toExplicitEdge(g, e), CoreMatchers .is(CoreMatchers.sameInstance(e))); } } }
@Test public void toExplicitEdge() { Graph g = new Graph(2); Atom u = Mockito.mock(Atom.class); Atom v = Mockito.mock(Atom.class); Mockito.when(u.aromatic()).thenReturn(false); Mockito.when(v.aromatic()).thenReturn(false); g.addAtom(u); g.addAtom(v); Edge e = new Edge(0, 1, IMPLICIT); Assert.assertThat(ImplicitToExplicit.toExplicitEdge(g, e), CoreMatchers.is(CoreMatchers.not(CoreMatchers .sameInstance(e)))); Assert.assertThat(ImplicitToExplicit.toExplicitEdge(g, e), CoreMatchers.is(new Edge(0, 1, SINGLE))); }