### Question:
JcrNodeTypeManager implements NodeTypeManager { public boolean isDerivedFrom( String[] testTypeNames, String primaryTypeName, String[] mixinNames ) throws RepositoryException { CheckArg.isNotEmpty(testTypeNames, "testTypeNames"); CheckArg.isNotEmpty(primaryTypeName, "primaryTypeName"); NameFactory nameFactory = context().getValueFactories().getNameFactory(); Name[] typeNames = nameFactory.create(testTypeNames); for (Name typeName : typeNames) { JcrNodeType nodeType = getNodeType(typeName); if ((nodeType != null) && nodeType.isNodeType(primaryTypeName)) { return true; } } if (mixinNames != null) { for (String mixin : mixinNames) { for (Name typeName : typeNames) { JcrNodeType nodeType = getNodeType(typeName); if ((nodeType != null) && nodeType.isNodeType(mixin)) { return true; } } } } return false; } JcrNodeTypeManager( JcrSession session,
                        RepositoryNodeTypeManager repositoryTypeManager ); NodeTypeIterator getAllNodeTypes(); NodeTypeIterator getMixinNodeTypes(); JcrNodeType getNodeType( String nodeTypeName ); boolean hasNodeType( String nodeTypeName ); NodeTypeIterator getPrimaryNodeTypes(); NodeType registerNodeType( NodeTypeDefinition template,
                                      boolean allowUpdate ); NodeTypeIterator registerNodeTypes( Collection<NodeTypeDefinition> templates,
                                               boolean allowUpdates ); NodeTypeIterator registerNodeTypes( Iterable<NodeTypeDefinition> nodeTypes ); NodeTypeIterator registerNodeTypes( NodeTypeDefinition[] ntds,
                                               boolean allowUpdate ); void unregisterNodeType( String nodeTypeName ); void unregisterNodeTypes( Collection<String> nodeTypeNames ); void unregisterNodeTypes( String[] names ); NodeTypeTemplate createNodeTypeTemplate(); @SuppressWarnings( "unchecked" ) NodeTypeTemplate createNodeTypeTemplate( NodeTypeDefinition ntd ); NodeDefinitionTemplate createNodeDefinitionTemplate(); PropertyDefinitionTemplate createPropertyDefinitionTemplate(); boolean isDerivedFrom( String[] testTypeNames,
                                  String primaryTypeName,
                                  String[] mixinNames );  }### Answer:
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowNullSubTypeNames() throws RepositoryException { this.nodeTypeMgr.isDerivedFrom(null, "nt:base", MIXINS); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowEmptySubTypeNames() throws Exception { this.nodeTypeMgr.isDerivedFrom(new String[0], "nt:base", MIXINS); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowNullPrimaryType() throws Exception { this.nodeTypeMgr.isDerivedFrom(SUBTYPES, null, MIXINS); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowEmptyPrimaryType() throws Exception { this.nodeTypeMgr.isDerivedFrom(SUBTYPES, "", MIXINS); }
@Test public void shouldBeDerivedFromIfSubtypeMatchesPrimaryType() throws Exception { assertTrue(this.nodeTypeMgr.isDerivedFrom(SUBTYPES, SUBTYPE2, null)); assertTrue(this.nodeTypeMgr.isDerivedFrom(SUBTYPES, SUBTYPE2, MIXINS)); }
@Test public void shouldBeDerivedFromIfSubtypeMatchesMixin() throws Exception { assertTrue(this.nodeTypeMgr.isDerivedFrom(new String[] {MIXIN2}, SUBTYPE1, MIXINS)); }
@Test public void shouldBeDerivedFromIfSubtypeIsActualSubType() throws Exception { assertTrue(this.nodeTypeMgr.isDerivedFrom(SUBTYPES, HIERARCHY_NODE_TYPE, MIXINS)); }
@Test public void shouldNotBeDerivedFromIfNoMatch() throws Exception { assertFalse(this.nodeTypeMgr.isDerivedFrom(SUBTYPES, NO_MATCH_TYPE, MIXINS)); }