private static SoapMockResponse createSoapMockResponse(final String defaultBody){ final SoapMockResponse mockResponse = new SoapMockResponse(); mockResponse.setBody(defaultBody); mockResponse.setStatus(SoapMockResponseStatus.ENABLED); mockResponse.setName(AUTO_GENERATED_MOCK_RESPONSE_DEFAULT_NAME); mockResponse.setHttpStatusCode(DEFAULT_HTTP_STATUS_CODE); return mockResponse; }
public static SoapResource generateSoapResource(){ final SoapResource soapResource = new SoapResource(); soapResource.setId("SOAP RESOURCE"); soapResource.setName("Soap resource name"); soapResource.setProjectId("Project id"); soapResource.setType(SoapResourceType.WSDL); soapResource.setContent(""); return soapResource; } }
/** * The method provides the functionality to convert an instance (parent) to an instance of a subclass to the * provided parent. * @param parent The parent that will be converted into a subtype of the provided parent * @return A new instance of the parent, but as a subtype of the parent */ @Override public SoapProject convertType(Project parent) { return new SoapProject(parent); }
public static SoapOperation generateSoapOperation(){ final SoapOperation soapOperation = new SoapOperation(); soapOperation.setId("SOAP OPERATION"); soapOperation.setName("Soap operation name"); soapOperation.setCurrentResponseSequenceIndex(1); soapOperation.setDefaultBody("Default body"); soapOperation.setForwardedEndpoint("Forwarded event"); soapOperation.setInvokeAddress("Invoke address"); soapOperation.setOriginalEndpoint("Original endpoint"); soapOperation.setHttpMethod(HttpMethod.POST); soapOperation.setStatus(SoapOperationStatus.MOCKED); soapOperation.setSoapVersion(SoapVersion.SOAP11); soapOperation.setIdentifyStrategy(SoapOperationIdentifyStrategy.ELEMENT_NAMESPACE); soapOperation.setMockResponses(new ArrayList<SoapMockResponse>()); return soapOperation; } }
public static SoapMockResponse generateSoapMockResponse(){ final SoapXPathExpression soapXPathExpression1 = new SoapXPathExpression(); final SoapXPathExpression soapXPathExpression2 = new SoapXPathExpression(); soapXPathExpression1.setExpression("//Request/Name[text()='Input1']"); soapXPathExpression2.setExpression("//Request/Name[text()='Input2']"); final SoapMockResponse soapMockResponse = new SoapMockResponse(); soapMockResponse.setName("Soap mock response name"); soapMockResponse.setBody("Soap mock response body"); soapMockResponse.setId("SOAP MOCK RESPONSE"); soapMockResponse.setXpathExpression("//Request/Name[text()='Input1']"); soapMockResponse.setXpathExpressions(Arrays.asList(soapXPathExpression1, soapXPathExpression2)); soapMockResponse.setStatus(SoapMockResponseStatus.ENABLED); return soapMockResponse; } }
private SoapOperation createSoapOperation(String portId, HttpMethod method, SoapVersion soapVersion, String identifierName, String namespace) { SoapOperation soapOperation = new SoapOperation(); soapOperation.setPortId(portId); soapOperation.setHttpMethod(method); soapOperation.setSoapVersion(soapVersion); soapOperation.setIdentifyStrategy(SoapOperationIdentifyStrategy.ELEMENT_NAMESPACE); SoapOperationIdentifier soapOperationIdentifier = new SoapOperationIdentifier(); soapOperationIdentifier.setName(identifierName); soapOperationIdentifier.setNamespace(namespace); soapOperation.setOperationIdentifier(soapOperationIdentifier); return soapOperation; }
private void verify(final SoapPort soapPort, final String name, final SoapVersion soapVersion){ Assert.assertEquals(name + ".Endpoint", soapPort.getName()); Assert.assertEquals(name + ".Endpoint", soapPort.getUri()); Assert.assertEquals(1, soapPort.getOperations().size()); SoapOperation soapOperation = soapPort.getOperations().get(0); Assert.assertEquals(name, soapOperation.getName()); Assert.assertEquals(SoapResponseStrategy.RANDOM, soapOperation.getResponseStrategy()); Assert.assertEquals(SoapOperationStatus.MOCKED, soapOperation.getStatus()); Assert.assertEquals(soapVersion, soapOperation.getSoapVersion()); Assert.assertEquals(HttpMethod.POST, soapOperation.getHttpMethod()); SoapOperationIdentifier operationIdentifier = soapOperation.getOperationIdentifier(); Assert.assertNotNull(operationIdentifier); Assert.assertEquals("Request", operationIdentifier.getName()); Assert.assertEquals("http://Services/ServiceExample/ServiceExample/1/Schema", operationIdentifier.getNamespace()); }
public static SoapProject generateSoapProject(){ final SoapProject project = new SoapProject(); project.setId("SOAP PROJECT"); project.setName("Project name"); project.setDescription("Project description"); project.setCreated(new Date()); project.setUpdated(new Date()); project.setPorts(new ArrayList<SoapPort>()); return project; }
private SoapProject getSoapProject(){ final SoapProject soapProject = new SoapProject(); final SoapResource soapResource = new SoapResource(); soapResource.setId("Resource id"); soapResource.setName("wsdl"); soapResource.setType(SoapResourceType.WSDL); soapProject.setResources(Arrays.asList(soapResource)); return soapProject; }
public static SoapPort generateSoapPort(){ final SoapPort soapPort = new SoapPort(); soapPort.setId("SOAP PORT"); soapPort.setName("Soap port name"); soapPort.setUri("UrlPath"); soapPort.setOperations(new ArrayList<SoapOperation>()); return soapPort; }
private SoapOperation createSoapOperation(String portId, String name) { SoapOperation soapOperation = new SoapOperation(); soapOperation.setName(name); soapOperation.setPortId(portId); return soapOperation; }
private SoapMockResponse createSoapMockResponse(String name) { SoapMockResponse dto = new SoapMockResponse(); dto.setName(name); return dto; } }
private SoapProject createSoapProject(String name) { SoapProject soapProject = new SoapProject(); soapProject.setName(name); return soapProject; } }
/** * The method provides the functionality to generate a new mocked response * @return A string value of the response */ private static String generateDefaultBody(final SoapOperationIdentifier operationResponseIdentifier){ final String prefix = "web"; return "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:" + prefix + "=\"" + operationResponseIdentifier.getNamespace() + "\">\n" + " <soapenv:Header/>\n" + " <soapenv:Body>\n" + " <" + prefix + ":" + operationResponseIdentifier.getName() + ">?</" + prefix + ":" + operationResponseIdentifier.getName() + ">\n" + " </soapenv:Body>\n" + "</soapenv:Envelope>"; } }
protected SoapProject deleteProject(final String projectId){ final List<SoapPort> ports = this.portRepository.findWithProjectId(projectId); final List<SoapResource> resources = this.resourceRepository.findWithProjectId(projectId); ports.forEach(port -> this.deletePort(port.getId())); resources.forEach(resource -> this.deleteResource(resource.getId())); return this.repository.delete(projectId); }
private Optional<SoapMockResponse> getDefaultMockResponse(final SoapOperation soapOperation, final List<SoapMockResponse> mockResponses){ final String defaultResponseId = soapOperation.getDefaultMockResponseId(); if(defaultResponseId != null && !defaultResponseId.isEmpty()){ LOGGER.info("Use the default response"); for (SoapMockResponse tmpMockResponse : mockResponses) { if(defaultResponseId.equals(tmpMockResponse.getId())){ return Optional.of(tmpMockResponse); } } LOGGER.error("Unable to find the default response"); } return Optional.empty(); }
/** * Count the operation statuses * @param soapOperations The list of operations, which status will be counted * @return The result of the status count */ private Map<SoapOperationStatus, Integer> getSoapOperationStatusCount(final List<SoapOperation> soapOperations){ Preconditions.checkNotNull(soapOperations, "The operation list cannot be null"); final Map<SoapOperationStatus, Integer> statuses = new HashMap<SoapOperationStatus, Integer>(); for(SoapOperationStatus soapOperationStatus : SoapOperationStatus.values()){ statuses.put(soapOperationStatus, 0); } for(SoapOperation soapOperation : soapOperations){ SoapOperationStatus soapOperationStatus = soapOperation.getStatus(); statuses.put(soapOperationStatus, statuses.get(soapOperationStatus)+1); } return statuses; } }
/** * The method adds a new {@link SoapResource}. * * @param soapResource The instance of {@link SoapResource} that will be saved. * @param resource The raw resource * @return The saved {@link SoapResource} * @see SoapResource */ @Override public SoapResource saveSoapResource(SoapResource soapResource, String resource) { soapResource.setContent(resource); return save(soapResource); }
public static SoapVersion convert(final String contextType) { if(contextType.contains(SOAP12.getContextType())){ return SOAP12; } // Return SOAP 1.1 as default return SOAP11; } }