### Question:
StringToNodeInclusionPolicy extends StringToInclusionPolicy<NodeInclusionPolicy> { public static StringToNodeInclusionPolicy getInstance() { return INSTANCE; }  static StringToNodeInclusionPolicy getInstance();  }### Answer:
@Test public void shouldConstructPolicyFromAllNodesKeywords() { NodeInclusionPolicy policy1 = StringToNodeInclusionPolicy.getInstance().apply("all"); assertNotNull(policy1); assertEquals(IncludeAllBusinessNodes.getInstance(), policy1); NodeInclusionPolicy policy2 = StringToNodeInclusionPolicy.getInstance().apply("true"); assertNotNull(policy2); assertEquals(IncludeAllBusinessNodes.getInstance(), policy2); }
@Test public void shouldConstructPolicyFromExcludeAllNodesKeywords() { NodeInclusionPolicy policy1 = StringToNodeInclusionPolicy.getInstance().apply("false"); assertNotNull(policy1); assertEquals(IncludeNoNodes.getInstance(), policy1); NodeInclusionPolicy policy2 = StringToNodeInclusionPolicy.getInstance().apply("none"); assertNotNull(policy2); assertEquals(IncludeNoNodes.getInstance(), policy2); }
@Test public void shouldConstructPolicyFromClassName() { NodeInclusionPolicy policy = StringToNodeInclusionPolicy.getInstance().apply("com.graphaware.runtime.config.function.SingletonNodeInclusionPolicy"); assertNotNull(policy); assertEquals(of(IncludeAllBusinessNodes.getInstance(), SingletonNodeInclusionPolicy.getInstance()), policy); }
@Test public void shouldConstructPolicyFromClassName2() { NodeInclusionPolicy policy = StringToNodeInclusionPolicy.getInstance().apply("com.graphaware.runtime.config.function.TestNodeInclusionPolicy"); assertNotNull(policy); assertEquals(of(IncludeAllBusinessNodes.getInstance(), new TestNodeInclusionPolicy()), policy); }
@Test public void shouldConstructSpelPolicy() { NodeInclusionPolicy policy = StringToNodeInclusionPolicy.getInstance().apply("hasLabel('Test')"); assertEquals(of(IncludeAllBusinessNodes.getInstance(), new SpelNodeInclusionPolicy("hasLabel('Test')")), policy); }
@Test public void shouldConstructSpelPolicy2() { NodeInclusionPolicy policy = StringToNodeInclusionPolicy.getInstance().apply("isType('R1')"); assertEquals(of(IncludeAllBusinessNodes.getInstance(), new SpelNodeInclusionPolicy("isType('R1')")), policy); }
@Test(expected = RuntimeException.class) public void uninstantiableClassCausesException() { StringToNodeInclusionPolicy.getInstance().apply("com.graphaware.runtime.config.function.WrongNodeInclusionPolicy"); }