private static SoapOperationIdentifier createSoapOperationIdentifier(final MessagePart messagePart, final Set<Namespace> namespaces){ final Attribute elementAttribute = messagePart.getElement(); final String name = elementAttribute.getLocalName(); final String namespace = elementAttribute.getNamespace() .map(namespaceName -> namespaces.stream() .filter(namespace1 -> namespace1.getLocalName().equals(namespaceName)) .findFirst() .map(Namespace::getValue).orElse(null)) .orElse(null); final SoapOperationIdentifier operationIdentifier = new SoapOperationIdentifier(); operationIdentifier.setName(name); operationIdentifier.setNamespace(namespace); return operationIdentifier; }
operationIdentifier.setNamespace(namespace); operationIdentifier.setName(elementName.getLocalName());
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; }
@Test public void testFindWithMethodAndVersionAndIdentifier() { SoapOperation shouldMatch = soapOperationMongoRepository .save(createSoapOperation("port1", HttpMethod.POST, SoapVersion.SOAP12, "id1", "xn")); soapOperationMongoRepository.save(createSoapOperation("port1", HttpMethod.POST, SoapVersion.SOAP12, "id1", "xy")); soapOperationMongoRepository.save(createSoapOperation("port1", HttpMethod.POST, SoapVersion.SOAP12, "id2", "xz")); soapOperationMongoRepository.save(createSoapOperation("port1", HttpMethod.POST, SoapVersion.SOAP11, "id1", "xx")); SoapOperationIdentifier soapOperationIdentifier = new SoapOperationIdentifier(); soapOperationIdentifier.setName("id1"); soapOperationIdentifier.setNamespace("xn"); SoapOperation result = soapOperationMongoRepository.findWithMethodAndVersionAndIdentifier("port1", HttpMethod.POST, SoapVersion.SOAP12, soapOperationIdentifier); assertThat(result).isEqualToComparingFieldByFieldRecursively(shouldMatch); }