SkinFactory { public GJointSkin createJointSkin(final GJoint joint) { if (joint == null) { return null; } else if (joint.getType() == null) { return new DefaultJointSkin(joint); } final Class<? extends GJointSkin> skinClass = jointSkins.get(joint.getType()); if (skinClass == null) { return new DefaultJointSkin(joint); } else { try { final Constructor<? extends GJointSkin> constructor = skinClass.getConstructor(GJoint.class); return constructor.newInstance(joint); } catch (final ReflectiveOperationException e) { LOGGER.error(LogMessages.CANNOT_INSTANTIATE_SKIN, skinClass.getName()); return new DefaultJointSkin(joint); } } }  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 testCreateJointSkin() { JOINT.setType(null); assertNull(skinFactory.createJointSkin(null)); assertTrue(skinFactory.createJointSkin(JOINT) instanceof DefaultJointSkin); JOINT.setType(JOINT_TYPE); assertTrue(skinFactory.createJointSkin(JOINT) instanceof DefaultJointSkin); skinFactory.setJointSkin(JOINT_TYPE, CustomJointSkin.class); assertTrue(skinFactory.createJointSkin(JOINT) instanceof CustomJointSkin); }