### Question:
Evaluators { public static Evaluator evaluatorFor(String macroName, Integer instanceNum) throws SyntaxException { if (macroName.equals(Type.CLUSTER_OWNER.prefix)) { return new ClusterOwnerEvaluator(); } else if (macroName.equals(Type.HOST_SELF.prefix)) { return new HostSelfEvaluator(); } else if (macroName.startsWith(Type.HOST_OF_SERVICE.prefix)) { String service = Type.HOST_OF_SERVICE.stripPrefix(macroName); checkService(service); return new HostServiceEvaluator(service, instanceNum); } else if (macroName.startsWith(Type.NUM_OF_NODES_WITH_SERVICE.prefix)) { String service = Type.NUM_OF_NODES_WITH_SERVICE.stripPrefix(macroName); checkService(service); return new ServiceCardinalityEvaluator(service); } else if (macroName.startsWith(Type.INSTANCE_OF_SERVICE.prefix)) { String service = Type.INSTANCE_OF_SERVICE.stripPrefix(macroName); checkService(service); return new ServiceInstanceEvaluator(service); } else if (macroName.startsWith(Type.IP.prefix)) { String ipStripped = Type.IP.stripPrefix(macroName); String[] ipMacroParts = ipStripped.split("\\.", 3); int numParts = ipMacroParts.length; if ("self".equals(ipStripped)) { return new IPSelfEvaluator(DEFAULT_IP_TYPE); } else if (numParts == 2 && "service".equals(ipMacroParts[0])) { return new IPServiceEvaluator(ipMacroParts[1], DEFAULT_IP_TYPE, instanceNum); } else if (numParts == 2 && ipMacroParts[1].equals("self")) { return new IPSelfEvaluator(ipMacroParts[0]); } else if (numParts == 3 && ipMacroParts[1].equals("service")) { String service = ipMacroParts[2]; return new IPServiceEvaluator(service, ipMacroParts[0], instanceNum); } } throw new SyntaxException("'" + macroName + "' is not a valid macro name"); }  static Evaluator evaluatorFor(String macroName, Integer instanceNum);  }### Answer:
@Test public void testParseMacroName() throws SyntaxException { Assert.assertEquals(new HostServiceEvaluator("abc", null), Evaluators.evaluatorFor("host.service.abc", null)); Assert.assertEquals(new IPServiceEvaluator("abc", "access_v4", null), Evaluators.evaluatorFor("ip.access_v4.service.abc", null)); Assert.assertEquals(new IPServiceEvaluator("abc", "bind_v4", null), Evaluators.evaluatorFor("ip.service.abc", null)); Assert.assertTrue(Evaluators.evaluatorFor("cluster.owner", null) instanceof ClusterOwnerEvaluator); for (String macro : ImmutableList.of("", "host.service.", "IP_OF_SERVICE.abc", "SERVICE_BULLSHIT_abc")) { try { Evaluators.evaluatorFor(macro, null); Assert.fail("'" + macro + "' should have thrown syntax exception."); } catch (SyntaxException e) { } } }