@Test public void testApplyProfileMetaDataChanges() throws IOException { String p = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/Profile.xml")); String v = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/ValueSets_all.xml")); String c = IOUtils.toString(this.getClass().getResourceAsStream("/vxuTest/Constraints.xml")); Profile p1 = new ProfileSerializationImpl().deserializeXMLToProfile(p, v, c); String jsonChanges = "\r\n\r\n {\r\n \"profile\": {\r\n \"edit\": [\r\n {\r\n \"id\": \"552014603004d0a9f09caf16\",\r\n \"identifier\": \"ddddddddddddd\",\r\n \"subTitle\": \"ddddddddd\",\r\n \"orgName\": \"NISTddddd\",\r\n \"name\": \"VXU_V04ddddd\"\r\n }\r\n ]\r\n }\r\n}\r\n "; try { p1 = profileService.apply(p1); assertEquals("ddddddddddddd", p1.getMetaData().getProfileID()); assertEquals("ddddddddd", p1.getMetaData().getSubTitle()); assertEquals("NISTddddd", p1.getMetaData().getOrgName()); assertEquals("VXU_V04ddddd", p1.getMetaData().getName()); // assertEquals(jsonChanges, p1.getChanges()); } catch (ProfileSaveException e) { if (e.getErrors() != null && !e.getErrors().isEmpty()) { for (ProfilePropertySaveError error : e.getErrors()) { System.out.println(error); } } } }
public ElementVerification verifyUsage( Profile p, Profile baseP, String id, String type, String eltName, String eltValue) { // Type can be SegmentRef, Group, Field, Component, Code // EltName is Usage String hl7Version = p.getMetaData().getHl7Version(); Usage referenceUsage = Usage.R; Usage currentUsage = Usage.R; switch (type) { case "segmentRef": SegmentRefOrGroup srog = p.getMessages().findOneSegmentRefOrGroup(id); currentUsage = srog.getUsage(); SegmentRefOrGroup basesrog = baseP.getMessages().findOneSegmentRefOrGroup(id); referenceUsage = basesrog.getUsage(); break; case "group": SegmentRefOrGroup srog_ = p.getMessages().findOneSegmentRefOrGroup(id); currentUsage = srog_.getUsage(); SegmentRefOrGroup basesrog_ = baseP.getMessages().findOneSegmentRefOrGroup(id); referenceUsage = basesrog_.getUsage(); break; case "field": // Field f = p.getSegmentLibrary().findOneField(id); // currentUsage = f.getUsage(); // Field basef = baseP.getSegmentLibrary().findOneField(id); // referenceUsage = basef.getUsage(); break; case "component": // Component c = p.getDatatypeLibrary().findOneComponent(id); // currentUsage = c.getUsage(); // Component basec = baseP.getDatatypeLibrary().findOneComponent(id); // referenceUsage = basec.getUsage(); break; case "code": // Code cd = p.getTableLibrary().findOneCodeById(id); // currentUsage = Usage.fromValue(cd.getCodeUsage()); // Code basecd = baseP.getTableLibrary().findOneCodeById(id); // referenceUsage = Usage.fromValue(basecd.getCodeUsage()); break; } String result = this.validateChangeUsage(hl7Version, referenceUsage, currentUsage); ElementVerification ev = new ElementVerification(id, type); ElementVerificationResult evRst = new ElementVerificationResult(eltName, eltValue, result); ev.addElementVerifications(evRst); return ev; }