@Test public void testGenerateRequestString(){ RequestGenerator sut=spy(requestGenerator); when(sut.getDate()).thenReturn("2013-12-23T14:48:07-0500"); assertEquals("<Request xmlns=\"urn:oasis:names:tc:xacml:2.0:context:schema:os\" xmlns:xsi=\"http: }
public String generateRequestString(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId){ String date = getDate(); StringBuilder requestStringBuilder = new StringBuilder(); requestStringBuilder.append("<Request xmlns=\"urn:oasis:names:tc:xacml:2.0:context:schema:os\" "); requestStringBuilder.append("xmlns:xsi=\"http: requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(recepientSubjectNPI); requestStringBuilder.append("</AttributeValue> </Attribute> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(intermediarySubjectNPI); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> <Attribute AttributeId=\"gov.samhsa.consent2share.purpose-of-use-code\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(purposeOfUse); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> </Subject> <Resource> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(patientId); requestStringBuilder.append("</AttributeValue> </Attribute> </Resource> "); requestStringBuilder.append("<Action> <Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("</Attribute> </Action> <Environment> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(date); requestStringBuilder.append("</AttributeValue> </Attribute> </Environment> </Request>"); return requestStringBuilder.toString(); }
RequestGenerator { public String generateRequestString(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId){ String date = getDate(); StringBuilder requestStringBuilder = new StringBuilder(); requestStringBuilder.append("<Request xmlns=\"urn:oasis:names:tc:xacml:2.0:context:schema:os\" "); requestStringBuilder.append("xmlns:xsi=\"http: requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(recepientSubjectNPI); requestStringBuilder.append("</AttributeValue> </Attribute> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(intermediarySubjectNPI); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> <Attribute AttributeId=\"gov.samhsa.consent2share.purpose-of-use-code\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(purposeOfUse); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> </Subject> <Resource> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(patientId); requestStringBuilder.append("</AttributeValue> </Attribute> </Resource> "); requestStringBuilder.append("<Action> <Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("</Attribute> </Action> <Environment> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(date); requestStringBuilder.append("</AttributeValue> </Attribute> </Environment> </Request>"); return requestStringBuilder.toString(); } }
RequestGenerator { public String generateRequestString(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId){ String date = getDate(); StringBuilder requestStringBuilder = new StringBuilder(); requestStringBuilder.append("<Request xmlns=\"urn:oasis:names:tc:xacml:2.0:context:schema:os\" "); requestStringBuilder.append("xmlns:xsi=\"http: requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(recepientSubjectNPI); requestStringBuilder.append("</AttributeValue> </Attribute> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(intermediarySubjectNPI); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> <Attribute AttributeId=\"gov.samhsa.consent2share.purpose-of-use-code\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(purposeOfUse); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> </Subject> <Resource> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(patientId); requestStringBuilder.append("</AttributeValue> </Attribute> </Resource> "); requestStringBuilder.append("<Action> <Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("</Attribute> </Action> <Environment> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(date); requestStringBuilder.append("</AttributeValue> </Attribute> </Environment> </Request>"); return requestStringBuilder.toString(); }  }
RequestGenerator { public String generateRequestString(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId){ String date = getDate(); StringBuilder requestStringBuilder = new StringBuilder(); requestStringBuilder.append("<Request xmlns=\"urn:oasis:names:tc:xacml:2.0:context:schema:os\" "); requestStringBuilder.append("xmlns:xsi=\"http: requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(recepientSubjectNPI); requestStringBuilder.append("</AttributeValue> </Attribute> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(intermediarySubjectNPI); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> <Attribute AttributeId=\"gov.samhsa.consent2share.purpose-of-use-code\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(purposeOfUse); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> </Subject> <Resource> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(patientId); requestStringBuilder.append("</AttributeValue> </Attribute> </Resource> "); requestStringBuilder.append("<Action> <Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("</Attribute> </Action> <Environment> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(date); requestStringBuilder.append("</AttributeValue> </Attribute> </Environment> </Request>"); return requestStringBuilder.toString(); }  RequestType generateRequest(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId); String generateRequestString(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId); String getDate(); }
RequestGenerator { public String generateRequestString(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId){ String date = getDate(); StringBuilder requestStringBuilder = new StringBuilder(); requestStringBuilder.append("<Request xmlns=\"urn:oasis:names:tc:xacml:2.0:context:schema:os\" "); requestStringBuilder.append("xmlns:xsi=\"http: requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(recepientSubjectNPI); requestStringBuilder.append("</AttributeValue> </Attribute> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(intermediarySubjectNPI); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> <Attribute AttributeId=\"gov.samhsa.consent2share.purpose-of-use-code\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append(purposeOfUse); requestStringBuilder.append("</AttributeValue> "); requestStringBuilder.append("</Attribute> </Subject> <Resource> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:resource:resource-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(patientId); requestStringBuilder.append("</AttributeValue> </Attribute> </Resource> "); requestStringBuilder.append("<Action> <Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:action:action-id\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("</Attribute> </Action> <Environment> "); requestStringBuilder.append("<Attribute AttributeId=\"urn:oasis:names:tc:xacml:1.0:environment:current-dateTime\" "); requestStringBuilder.append("DataType=\"http: requestStringBuilder.append("<AttributeValue>"); requestStringBuilder.append(date); requestStringBuilder.append("</AttributeValue> </Attribute> </Environment> </Request>"); return requestStringBuilder.toString(); }  RequestType generateRequest(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId); String generateRequestString(String recepientSubjectNPI, String intermediarySubjectNPI, String purposeOfUse, String patientId); String getDate();  }