Commit 1f0b0e01 authored by Malo Toudic's avatar Malo Toudic
Browse files
parent 67276c0a
package net.ihe.gazelle.wstester.action;
import net.ihe.gazelle.evsclient.connector.api.EVSClientResults;
import net.ihe.gazelle.evsclient.connector.api.EVSClientServletConnector;
import net.ihe.gazelle.evsclient.connector.model.EVSClientValidatedObject;
import net.ihe.gazelle.evsclient.connector.utils.PartSourceUtils;
import net.ihe.gazelle.hql.providers.EntityManagerService;
import net.ihe.gazelle.simulator.common.model.ApplicationConfiguration;
import net.ihe.gazelle.wstester.model.GwtTestStepResult;
import net.ihe.gazelle.wstester.model.ValidationResult;
import org.apache.commons.httpclient.methods.multipart.PartSource;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.international.StatusMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import java.io.IOException;
import java.util.Map;
@Name("messageValidation")
@Scope(ScopeType.PAGE)
public class GwtTestStepValidation implements EVSClientValidatedObject {
private static final Logger LOG = LoggerFactory.getLogger(GwtTestStepValidation.class);
String gwtTestStepResultId;
byte[] selectedMessage;
GwtTestStepResult gwtTestStepResultSelected;
ValidationResult validationResult;
public GwtTestStepValidation() {
}
public GwtTestStepValidation(String gwtTestStepResultId, byte[] selectedMessage) {
this.gwtTestStepResultId = gwtTestStepResultId;
this.selectedMessage = selectedMessage;
}
public byte[] getSelectedMessage() {
return selectedMessage;
}
public void setSelectedMessage(byte[] selectedMessage) {
this.selectedMessage = selectedMessage;
}
public String getGwtTestStepResultId() {
return gwtTestStepResultId;
}
public void setGwtTestStepResultId(String gwtTestStepResultId) {
this.gwtTestStepResultId = gwtTestStepResultId;
}
public GwtTestStepResult getGwtTestStepResultSelected() {
return gwtTestStepResultSelected;
}
public void setGwtTestStepResultSelected(GwtTestStepResult gwtTestStepResultSelected) {
this.gwtTestStepResultSelected = gwtTestStepResultSelected;
}
public ValidationResult getValidationResult() {
return validationResult;
}
public void setValidationResult(ValidationResult validationResult) {
this.validationResult = validationResult;
}
@Create
public void initializePage() {
Map<String, String> urlParams = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String[] parts = null;
if ((urlParams != null) && urlParams.containsKey("id")) {
String externalId = ((String) urlParams.get("id"));
parts = externalId.split("_");
EntityManager entityManager = EntityManagerService.provideEntityManager();
gwtTestStepResultSelected = entityManager.find(GwtTestStepResult.class, Integer.parseInt(parts[0]));
if (gwtTestStepResultSelected == null) {
FacesMessages.instance().add(StatusMessage.Severity.ERROR, "The given id does not match any test step result in the database");
}
}
String validationOid = EVSClientResults.getResultOidFromUrl(urlParams);
if (validationOid != null && parts != null && parts[1] != null) {
ValidationResult result = new ValidationResult(gwtTestStepResultSelected, validationOid, parts[1]);
getResultDetails(result);
}
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("/gazelle-webservice-tester/executionResult.seam?id=" + gwtTestStepResultSelected.getExecution().getId());
} catch (IOException e) {
LOG.error(e.getMessage());
}
}
private void getResultDetails(final ValidationResult result) {
String evsclientUrl = ApplicationConfiguration.getValueOfVariable("evs_client_url");
String validationDate = EVSClientResults.getValidationDate(result.getOid(), evsclientUrl);
result.setValidationDate(validationDate);
String validationStatus = EVSClientResults.getValidationStatus(result.getOid(), evsclientUrl);
result.setValidationStatus(validationStatus);
String linkToResult = EVSClientResults.getValidationPermanentLink(result.getOid(), evsclientUrl);
result.setPermanentLink(linkToResult);
validationResult = result.save();
}
@Override
public String getUniqueKey() {
return gwtTestStepResultId;
}
@Override
public PartSource getPartSource() {
if (selectedMessage != null) {
//return new ByteArrayPartSource(getType(), selectedMessage);
return PartSourceUtils.buildEncoded64PartSource(selectedMessage, getType());
} else {
return null;
}
}
@Override
public String getType() {
return "xml";
}
public void validate() {
String evsClientUrl = ApplicationConfiguration.getValueOfVariable("evs_client_url");
String toolOid = ApplicationConfiguration.getValueOfVariable("tool_instance_oid");
if (evsClientUrl == null) {
LOG.error("evs_client_url is missing in app_configuration table");
} else if (toolOid == null) {
LOG.error("tool_instance_oid is missing in app_configuration table");
} else {
ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
EVSClientServletConnector.sendToValidation(this, extContext, evsClientUrl, toolOid);
}
}
}
......@@ -2,6 +2,7 @@ package net.ihe.gazelle.wstester.model;
import com.uwyn.jhighlight.renderer.XhtmlRendererFactory;
import net.ihe.gazelle.simulator.message.model.TransactionInstance;
import net.ihe.gazelle.wstester.action.GwtTestStepValidation;
import net.ihe.gazelle.wstester.util.DateUtil;
import net.ihe.gazelle.wstester.util.Xml;
import org.hibernate.annotations.Type;
......@@ -211,4 +212,29 @@ public class GwtTestStepResult implements Serializable {
return "unknown";
}
}
public void validateRequest() {
GwtTestStepValidation gwtTestStepValidation = new GwtTestStepValidation(id + "_request", messages.getRequest().getContent());
gwtTestStepValidation.validate();
}
public void validateResponse() {
GwtTestStepValidation gwtTestStepValidation = new GwtTestStepValidation(id + "_response", messages.getResponse().getContent());
gwtTestStepValidation.validate();
}
public ValidationResult getResponseValidation() {
ValidationResultQuery query = new ValidationResultQuery();
query.gwtTestStepResult().eq(this);
query.type().eq("response");
return query.getUniqueResult();
}
public ValidationResult getRequestValidation() {
ValidationResultQuery query = new ValidationResultQuery();
query.gwtTestStepResult().eq(this);
query.type().eq("request");
return query.getUniqueResult();
}
}
package net.ihe.gazelle.wstester.model;
import net.ihe.gazelle.hql.providers.EntityManagerService;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.io.Serializable;
@Entity
@Table(name = "gwt_validation_result")
@SequenceGenerator(name = "gwt_validation_result_sequence", sequenceName = "gwt_validation_result_id_seq", allocationSize = 1)
public class ValidationResult implements Serializable {
@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gwt_validation_result_sequence")
private Integer id;
@ManyToOne(targetEntity = GwtTestStepResult.class)
@JoinColumn(name = "test_step_result_id")
private GwtTestStepResult gwtTestStepResult;
@Column(name = "oid")
private String oid;
@Column(name = "type")
private String type;
@Column(name = "validation_date")
private String validationDate;
@Column(name = "validation_status")
private String validationStatus;
@Column(name = "permanent_link")
private String permanentLink;
public ValidationResult() {
super();
}
public ValidationResult(GwtTestStepResult selectedMessage, String oid, String type) {
this.gwtTestStepResult = selectedMessage;
this.oid = oid;
this.type = type;
}
public ValidationResult save() {
EntityManager entityManager = EntityManagerService.provideEntityManager();
ValidationResult result = entityManager.merge(this);
entityManager.flush();
return result;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public GwtTestStepResult getGwtTestStepResult() {
return gwtTestStepResult;
}
public void setGwtTestStepResult(GwtTestStepResult gwtTestStepResult) {
this.gwtTestStepResult = gwtTestStepResult;
}
public String getOid() {
return oid;
}
public void setOid(String oid) {
this.oid = oid;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValidationDate() {
return validationDate;
}
public void setValidationDate(String validationDate) {
this.validationDate = validationDate;
}
public String getValidationStatus() {
return validationStatus;
}
public void setValidationStatus(String validationStatus) {
this.validationStatus = validationStatus;
}
public String getPermanentLink() {
return permanentLink;
}
public void setPermanentLink(String permanentLink) {
this.permanentLink = permanentLink;
}
public boolean isRequest() {
if (type.equals("result")) {
return true;
} else {
return false;
}
}
public boolean isResponse() {
if (type.equals("response")) {
return true;
} else {
return false;
}
}
}
......@@ -87,25 +87,43 @@
</s:decorate>
</gri:panel>
<rich:dataTable id="summary" value="#{executionResult.execution.testStepResults}" var="testStepSummary">
<rich:dataTable id="summary" value="#{executionResult.execution.testStepResults}" var="testStepResult">
<g:column>
<ui:define name="header">Transaction</ui:define>
<h:outputText value="#{testStepSummary.testStep.label}"/>
<h:outputText value="#{testStepResult.testStep.label}"/>
</g:column>
<g:column>
<ui:define name="header">SoapUI Validation</ui:define>
<s:div>
<h:outputText value="#{testStepSummary.getStatusForCss()}"
styleClass="gzl-label #{testStepSummary.getStatusForCss()}"/>
<h:outputText value="#{testStepResult.getStatusForCss()}"
styleClass="gzl-label #{testStepResult.getStatusForCss()}"/>
</s:div>
</g:column>
<g:column>
<ui:define name="header">Request validation</ui:define>
<h:outputText value="Not yet implemented"/>
<s:div rendered="#{testStepResult.getRequestValidation() != null}">
<h:outputText value="#{testStepResult.getRequestValidation().validationStatus}"
styleClass="gzl-label #{testStepResult.getRequestValidation().validationStatus}"/>
</s:div>
<s:div rendered="#{testStepResult.getRequestValidation() == null}">
<h:commandLink actionListener="#{testStepResult.validateRequest()}"
target="_blank">
<s:span title="Validate request" styleClass="gzl-icon-play-blue"/>
</h:commandLink>
</s:div>
</g:column>
<g:column>
<ui:define name="header">Response validation</ui:define>
<h:outputText value="Not yet implemented"/>
<s:div rendered="#{testStepResult.getResponseValidation() != null}">
<h:outputText value="#{testStepResult.getResponseValidation().validationStatus}"
styleClass="gzl-label #{testStepResult.getResponseValidation().validationStatus}"/>
</s:div>
<s:div rendered="#{testStepResult.getResponseValidation() == null}">
<h:commandLink actionListener="#{testStepResult.validateResponse()}"
target="_blank">
<s:span title="Validate response" styleClass="gzl-icon-play-blue"/>
</h:commandLink>
</s:div>
</g:column>
<g:column>
<ui:define name="header">Cross-Validation</ui:define>
......@@ -115,13 +133,15 @@
<gri:tabPanel rendered="#{not empty executionResult.execution.testStepResults}" withBorder="true">
<c:forEach items="#{executionResult.execution.testStepResults}" var="testStepResult">
<gri:tab head="#{testStepResult.testStep.label}">
<s:div>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">SoapUI Validation</ui:define>
<h:outputText value="#{testStepResult.getStatusForCss()}"
styleClass="gzl-label #{testStepResult.getStatusForCss()}"/>
</s:div>
<br/>
</s:decorate>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">Endpoint</ui:define>
<h:outputText value="#{testStepResult.endpoint}"/>
......@@ -153,6 +173,31 @@
<h:outputText value="Request"/>
</f:facet>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">EVS Validation</ui:define>
<h:outputText value="#{testStepResult.getRequestValidation().validationStatus}"
styleClass="gzl-label #{testStepResult.getRequestValidation().validationStatus}"
rendered="#{testStepResult.getRequestValidation() != null}"/>
<h:commandLink actionListener="#{testStepResult.validateRequest()}"
rendered="#{testStepResult.getRequestValidation() == null}"
target="_blank">
<s:span title="Validate request" styleClass="gzl-icon-play-blue"/>
</h:commandLink>
</s:decorate>
<h:commandButton value="Re-validate" action="#{testStepResult.validateRequest()}"
styleClass="gzl-btn-blue"
onclick="this.form.target='_blank'"
rendered="#{testStepResult.getRequestValidation() != null}"/>
<s:decorate template="/layout/display/_display.xhtml"
rendered="#{testStepResult.getRequestValidation() != null}">
<ui:define name="label">EVS Validation permanent link</ui:define>
<h:outputLink value="#{testStepResult.getRequestValidation().permanentLink}" target="_blank">
<h:outputText value="#{testStepResult.getRequestValidation().permanentLink}"/>
</h:outputLink>
</s:decorate>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">Timestamp</ui:define>
<h:outputText value="#{testStepResult.getTimestamp()}"/>
......@@ -166,6 +211,31 @@
<h:outputText value="Response"/>
</f:facet>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">EVS Validation</ui:define>
<h:outputText value="#{testStepResult.getResponseValidation().validationStatus}"
styleClass="gzl-label #{testStepResult.getResponseValidation().validationStatus}"
rendered="#{testStepResult.getResponseValidation() != null}"/>
<h:commandLink actionListener="#{testStepResult.validateResponse()}"
rendered="#{testStepResult.getResponseValidation() == null}"
target="_blank">
<s:span title="Validate response" styleClass="gzl-icon-play-blue"/>
</h:commandLink>
</s:decorate>
<h:commandButton value="Re-validate" action="#{testStepResult.validateResponse()}"
styleClass="gzl-btn-blue"
onclick="this.form.target='_blank'"
rendered="#{testStepResult.getResponseValidation() != null}"/>
<s:decorate template="/layout/display/_display.xhtml"
rendered="#{testStepResult.getResponseValidation() != null}">
<ui:define name="label">EVS Validation permanent link</ui:define>
<h:outputLink value="#{testStepResult.getResponseValidation().permanentLink}" target="_blank">
<h:outputText value="#{testStepResult.getResponseValidation().permanentLink}"/>
</h:outputLink>
</s:decorate>
<s:decorate template="/layout/display/_display.xhtml">
<ui:define name="label">Timestamp</ui:define>
<h:outputText value="#{testStepResult.getResponseTimestamp()}"/>
......
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:s="http://jboss.org/schema/seam/taglib"
xmlns="http://www.w3.org/1999/xhtml" template="/layout/template.xhtml">
<ui:param name="pageNameTitle" value="Message validation"/>
<ui:define name="body">
<h:form id="globalForm">
<h1>#{messages['gazelle.ordermanager.DicomMessageDetails']}</h1>
<s:decorate template="/layout/panels/_panel.xhtml"
rendered="#{messageValidation.validationResult == null}">
<ui:param name="bodyStyleClass" value="bg-danger"/>
<span class="gzl-icon-exclamation-triangle"/>
<h:outputText
value="This id does not match any of the entries in the database']} !"/>
</s:decorate>
</h:form>
</ui:define>
</ui:composition>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment