SkinFactory { public GConnectorSkin createConnectorSkin(final GConnector connector) { if (connector == null) { return null; } else if (connector.getType() == null) { return new DefaultConnectorSkin(connector); } final Class<? extends GConnectorSkin> skinClass = connectorSkins.get(connector.getType()); if (skinClass == null) { return new DefaultConnectorSkin(connector); } else { try { final Constructor<? extends GConnectorSkin> constructor = skinClass.getConstructor(GConnector.class); return constructor.newInstance(connector); } catch (final ReflectiveOperationException e) { LOGGER.error(LogMessages.CANNOT_INSTANTIATE_SKIN, skinClass.getName()); return new DefaultConnectorSkin(connector); } } }  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 testCreateConnectorSkin() { CONNECTOR.setType(null); assertNull(skinFactory.createConnectorSkin(null)); assertTrue(skinFactory.createConnectorSkin(CONNECTOR) instanceof DefaultConnectorSkin); CONNECTOR.setType(CONNECTOR_TYPE); assertTrue(skinFactory.createConnectorSkin(CONNECTOR) instanceof DefaultConnectorSkin); CONNECTOR.setType(CONNECTOR_TYPE); skinFactory.setConnectorSkin(CONNECTOR_TYPE, CustomConnectorSkin.class); assertTrue(skinFactory.createConnectorSkin(CONNECTOR) instanceof CustomConnectorSkin); }