@Test public void testGetCategoryByName() throws Exception { Categories categories = new Categories(); categories.initCategories(); String actual = categories.getCategoryByName("Second").toString(); String expected = "Second"; Assert.assertEquals(actual, expected); }
/** @return */ public String toXML() { OptetPlugin optetPluginJAXB = new OptetPlugin(); for (Iterator iterator = categoriesList.iterator(); iterator.hasNext(); ) { Categories cates = (Categories) iterator.next(); com.thalesgroup.optet.plugin.template.jaxb.OptetPlugin.Categories categoriesJAXB = new com.thalesgroup.optet.plugin.template.jaxb.OptetPlugin.Categories(); categoriesJAXB.setName(cates.getName()); System.out.println("JAXB " + cates.getName()); Collection<Category> listcategory = cates.getCategories().values(); for (Iterator iterator2 = listcategory.iterator(); iterator2.hasNext(); ) { Category cat = (Category) iterator2.next(); com.thalesgroup.optet.plugin.template.jaxb.OptetPlugin.Categories.Category catJAXB = new com.thalesgroup.optet.plugin.template.jaxb.OptetPlugin.Categories.Category(); catJAXB.setName(cat.getName()); System.out.println("JAXB " + cat.getName()); Collection<Evidence> listevidence = cat.getMetrics().values(); for (Iterator iterator3 = listevidence.iterator(); iterator3.hasNext(); ) { Evidence evidence = (Evidence) iterator3.next(); com.thalesgroup.optet.plugin.template.jaxb.OptetPlugin.Categories.Category.Evidence evidenceJAXB = new com.thalesgroup.optet.plugin.template.jaxb.OptetPlugin.Categories.Category .Evidence(); evidenceJAXB.setName(evidence.getSummary()); System.out.println("JAXB " + evidence.getSummary()); catJAXB.getEvidence().add(evidenceJAXB); } categoriesJAXB.getCategory().add(catJAXB); } optetPluginJAXB.getCategories().add(categoriesJAXB); } JAXBContext jaxbContext; StringWriter stringWriter = new StringWriter(); try { jaxbContext = JAXBContext.newInstance(OptetPlugin.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); // output pretty printed jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.marshal(optetPluginJAXB, stringWriter); System.out.println("res " + stringWriter); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } // TODO Auto-generated method stub return stringWriter.toString(); }
public void init() { categoriesList = new ArrayList<Categories>(); Categories categories = new Categories("static"); Category category = new Category("SoftwareComplexity", categories); Evidence evidence = new Evidence("SoftwareComplexityMetric", category); category.getMetrics().put(evidence.getSummary(), evidence); categories.getCategories().put(category.getName(), category); category = new Category("Maintainability", categories); categories.getCategories().put(category.getName(), category); evidence = new Evidence("MaintainabilityMetric", category); category.getMetrics().put(evidence.getSummary(), evidence); category = new Category("Reliability", categories); categories.getCategories().put(category.getName(), category); evidence = new Evidence("ReliabilityMetric", category); category.getMetrics().put(evidence.getSummary(), evidence); category = new Category("Security", categories); categories.getCategories().put(category.getName(), category); evidence = new Evidence("SecurityMetric", category); category.getMetrics().put(evidence.getSummary(), evidence); categoriesList.add(categories); categories = new Categories("runtime"); category = new Category("UnitTest", categories); categories.getCategories().put(category.getName(), category); category = new Category("CodeCoverage", categories); categories.getCategories().put(category.getName(), category); categoriesList.add(categories); }
public boolean getCategories(String[] tabCommands) { lastResult = categorie.getCategories(); return (true); }
/** * Fügt die Kategorien hinzu. * * @param appointment Ein Rapla Appointment. */ private void addCategories(Appointment appointment, PropertyList properties) { Classification cls = appointment.getReservation().getClassification(); Categories cat = new Categories(); cat.getCategories().add(cls.getType().getName(raplaLocale.getLocale())); properties.add(cat); }