SkinFactory { public GConnectionSkin createConnectionSkin(final GConnection connection) { if (connection == null) { return null; } else if (connection.getType() == null) { return new DefaultConnectionSkin(connection); } final Class<? extends GConnectionSkin> skinClass = connectionSkins.get(connection.getType()); if (skinClass == null) { return new DefaultConnectionSkin(connection); } else { try { final Constructor<? extends GConnectionSkin> constructor = skinClass.getConstructor(GConnection.class); return constructor.newInstance(connection); } catch (final ReflectiveOperationException e) { LOGGER.error(LogMessages.CANNOT_INSTANTIATE_SKIN, skinClass.getName()); return new DefaultConnectionSkin(connection); } } }  void setNodeSkin(final String type, final Class<? extends GNodeSkin> skin); void setConnectorSkin(final String type, final Class<? extends GConnectorSkin> skin); void setConnectionSkin(final String type, final Class<? extends GConnectionSkin> skin); void setJointSkin(final String type, final Class<? extends GJointSkin> skin); void setTailSkin(final String type, final Class<? extends GTailSkin> skin); GNodeSkin createNodeSkin(final GNode node); GConnectorSkin createConnectorSkin(final GConnector connector); GConnectionSkin createConnectionSkin(final GConnection connection); GJointSkin createJointSkin(final GJoint joint); GTailSkin createTailSkin(final GConnector connector);  }
@Test public void testCreateConnectionSkin() { CONNECTION.setType(null); assertNull(skinFactory.createConnectionSkin(null)); assertTrue(skinFactory.createConnectionSkin(CONNECTION) instanceof DefaultConnectionSkin); CONNECTION.setType(CONNECTION_TYPE); assertTrue(skinFactory.createConnectionSkin(CONNECTION) instanceof DefaultConnectionSkin); skinFactory.setConnectionSkin(CONNECTION_TYPE, CustomConnectionSkin.class); assertTrue(skinFactory.createConnectionSkin(CONNECTION) instanceof CustomConnectionSkin); }