### Question:
NodeUtil { public static @Nonnull String getPrimaryType(@Nonnull Node node) throws RepositoryException { return node.hasProperty(JCR_PRIMARY_TYPE) ? node.getProperty(JCR_PRIMARY_TYPE).getString() : node.getPrimaryNodeType().getName(); } private  NodeUtil(); static @Nonnull String getPrimaryType(@Nonnull Node node); static @CheckForNull String geMixinTypes(@Nonnull Node node);  }### Answer:
@Test public void testRetrievalOfPrimaryNodeTypeViaApi() throws RepositoryException { withPrimaryType("nt:file"); assertThat(getPrimaryType(this.node)).isEqualTo("nt:file"); }
@Test public void testRetrievalOfPrimaryNodeTypeViaNodeProperty() throws RepositoryException { withJcrPrimaryTypeNodeProperty("nt:file"); assertThat(getPrimaryType(this.node)).isEqualTo("nt:file"); }
@Test public void testEfficientLookupOfPrimaryTypeViaPropertyTakesPrecedenceOverApiUsage() throws RepositoryException { withPrimaryType("via:Api"); withJcrPrimaryTypeNodeProperty("via:Property"); assertThat(getPrimaryType(this.node)).isEqualTo("via:Property"); }