@Test(dependsOnMethods = {"testInstantiation"}) public void testRegister() { NamingService<Node> srvNodes = NamingService.newNodeNS(); NamingService<VM> srvVMs = NamingService.newVMNS(); DefaultTemplateFactory tplf = new DefaultTemplateFactory(srvNodes, srvVMs, new DefaultModel()); MockVMTemplate t1 = new MockVMTemplate("mock1"); Assert.assertNull(tplf.register(t1)); Assert.assertEquals(t1.srvNodes, srvNodes); Assert.assertEquals(t1.srvVMs, srvVMs); Assert.assertTrue(tplf.getAvailables().contains("mock1")); MockVMTemplate t2 = new MockVMTemplate("mock2"); Assert.assertNull(tplf.register(t2)); Assert.assertEquals(t2.srvNodes, srvNodes); Assert.assertEquals(t2.srvVMs, srvVMs); Assert.assertTrue(tplf.getAvailables().contains("mock2") && tplf.getAvailables().size() == 2); }
@Override public Template register(Template tpl) { tpl.setNamingServiceNodes(namingServerNodes); tpl.setNamingServiceVMs(namingServerVMs); if (tpl.getElementType() == BtrpOperand.Type.VM) { return vmTpls.put(tpl.getIdentifier(), tpl); } else if (tpl.getElementType() == BtrpOperand.Type.NODE) { return nodeTpls.put(tpl.getIdentifier(), tpl); } return null; }
DefaultTemplateFactory implements TemplateFactory { @Override public Template register(Template tpl) { tpl.setNamingServiceNodes(namingServerNodes); tpl.setNamingServiceVMs(namingServerVMs); if (tpl.getElementType() == BtrpOperand.Type.VM) { return vmTpls.put(tpl.getIdentifier(), tpl); } else if (tpl.getElementType() == BtrpOperand.Type.NODE) { return nodeTpls.put(tpl.getIdentifier(), tpl); } return null; } }
DefaultTemplateFactory implements TemplateFactory { @Override public Template register(Template tpl) { tpl.setNamingServiceNodes(namingServerNodes); tpl.setNamingServiceVMs(namingServerVMs); if (tpl.getElementType() == BtrpOperand.Type.VM) { return vmTpls.put(tpl.getIdentifier(), tpl); } else if (tpl.getElementType() == BtrpOperand.Type.NODE) { return nodeTpls.put(tpl.getIdentifier(), tpl); } return null; } DefaultTemplateFactory(NamingService<Node> srvNodes, NamingService<VM> srvVMs, Model m); }
DefaultTemplateFactory implements TemplateFactory { @Override public Template register(Template tpl) { tpl.setNamingServiceNodes(namingServerNodes); tpl.setNamingServiceVMs(namingServerVMs); if (tpl.getElementType() == BtrpOperand.Type.VM) { return vmTpls.put(tpl.getIdentifier(), tpl); } else if (tpl.getElementType() == BtrpOperand.Type.NODE) { return nodeTpls.put(tpl.getIdentifier(), tpl); } return null; } DefaultTemplateFactory(NamingService<Node> srvNodes, NamingService<VM> srvVMs, Model m); @Override Set<String> getAvailables(); @Override boolean isAvailable(String id); @Override void check(Script scr, String tplName, Element e, Map<String, String> attrs); @Override Template register(Template tpl); }
DefaultTemplateFactory implements TemplateFactory { @Override public Template register(Template tpl) { tpl.setNamingServiceNodes(namingServerNodes); tpl.setNamingServiceVMs(namingServerVMs); if (tpl.getElementType() == BtrpOperand.Type.VM) { return vmTpls.put(tpl.getIdentifier(), tpl); } else if (tpl.getElementType() == BtrpOperand.Type.NODE) { return nodeTpls.put(tpl.getIdentifier(), tpl); } return null; } DefaultTemplateFactory(NamingService<Node> srvNodes, NamingService<VM> srvVMs, Model m); @Override Set<String> getAvailables(); @Override boolean isAvailable(String id); @Override void check(Script scr, String tplName, Element e, Map<String, String> attrs); @Override Template register(Template tpl);  }