@Test( groups = {"wso2.greg"}, description = "edit uri", dependsOnMethods = {"testAddTag"}) public void testEditURI() throws RegistryException { GovernanceUtils.loadGovernanceArtifacts((UserRegistry) governance); GenericArtifactManager artifactManager = new GenericArtifactManager(governance, "uri"); GenericArtifact artifact = artifactManager.getGenericArtifact(uriID); artifact.addAttribute("overview_description", utfString); Assert.assertTrue(artifact.getAttribute("overview_description").equals(utfString)); }
public ByteArrayOutputStream execute(String template, String type) throws IOException { Registry governanceRegistry; try { Registry registry = getRegistry(); governanceRegistry = GovernanceUtils.getGovernanceUserRegistry(registry, CurrentSession.getUser()); GenericArtifactManager suiteArtifactManager = new GenericArtifactManager(governanceRegistry, "suites"); GenericArtifact[] genericArtifacts = suiteArtifactManager.getAllGenericArtifacts(); GenericArtifactManager caseArtifactManager = new GenericArtifactManager(governanceRegistry, "case"); List<TestSuiteReportBean> beanList = new LinkedList<TestSuiteReportBean>(); for (GenericArtifact artifact : genericArtifacts) { TestSuiteReportBean bean = new TestSuiteReportBean(); String[] attributeKeys = artifact.getAttributeKeys(); List<String> testCases = new ArrayList<String>(); for (String key : attributeKeys) { if (key.equals("overview_name")) { String value = artifact.getAttribute(key); bean.setOverview_name(value); } else if (key.equals("overview_version")) { String value = artifact.getAttribute(key); bean.setOverview_version(value); } else if (key.equals("overview_type")) { String value = artifact.getAttribute(key); bean.setOverview_type(value); } if (key.equals("testCases_entry")) { String[] values = artifact.getAttributes(key); for (String value : values) { Resource r = registry.get( RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + value.split(":")[1]); GenericArtifact a = caseArtifactManager.getGenericArtifact(r.getUUID()); testCases.add(a.getAttribute("overview_name")); } } } bean.setTestCases_entry(testCases.toString().replaceAll("[ \\[\\] ]", "")); beanList.add(bean); } String templateContent = new String((byte[]) registry.get(template).getContent()); JRDataSource dataSource = new JRBeanCollectionDataSource(beanList); JasperPrint print = new JasperPrintProvider() .createJasperPrint(dataSource, templateContent, new ReportParamMap[0]); return new ReportStream().getReportStream(print, type.toLowerCase()); } catch (RegistryException e) { log.error("Error while getting the Governance Registry", e); } catch (JRException e) { log.error("Error occured while creating the jasper print ", e); } catch (ReportingException e) { log.error("Error while generating the report", e); } return new ByteArrayOutputStream(0); }