Skip to content

Commit

Permalink
Update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
MadhukaHarith92 committed Aug 10, 2023
1 parent bdeaf90 commit c0ceea6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
11 changes: 5 additions & 6 deletions ballerina/soap.bal
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ public type ClientConfiguration record {|
public isolated client class Client {

private final http:Client soapClient;
private final ClientConfiguration config;

private final SoapVersion soapVersion;
public function init(string url, *ClientConfiguration config) returns error? {
self.config = config;

self.soapVersion = config.soapVersion;
self.soapClient = check new (url,retrieveHttpClientConfig(config));
}

Expand All @@ -48,7 +46,8 @@ public isolated client class Client {
# + body - SOAP request body as an `XML` or `mime:Entity[]` to work with SOAP attachments
# + return - If successful, returns the response. Else, returns an error
remote function sendReceive(xml|mime:Entity[] body) returns xml|mime:Entity[]|error {
return sendReceive(self.config.soapVersion, body, self.soapClient);

return sendReceive(self.soapVersion, body, self.soapClient);
}

# Fire and forget requests. Sends the request without the possibility of any response from the
Expand All @@ -57,6 +56,6 @@ public isolated client class Client {
# + body - SOAP request body as an `XML` or `mime:Entity[]` to work with SOAP attachments
# + return - If successful, returns `nil`. Else, returns an error
remote function sendOnly(xml|mime:Entity[] body) returns error? {
return sendOnly(self.config.soapVersion, body, self.soapClient);
return sendOnly(self.soapVersion, body, self.soapClient);
}
}
9 changes: 5 additions & 4 deletions ballerina/tests/basic_client_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// under the License.

import ballerina/test;
import ballerina/mime;

@test:Config {}
function testSendReceive11() returns error? {
Expand All @@ -25,7 +26,7 @@ function testSendReceive11() returns error? {
<quer:LicenseKey>0</quer:LicenseKey>
</quer:CheckPhoneNumber>`;

var response = soapClient->sendReceive(body);
xml|mime:Entity[]|error response = check soapClient->sendReceive(body);

xml expected = xml `<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><CheckPhoneNumberResponse xmlns="http://ws.cdyne.com/PhoneVerify/query"><CheckPhoneNumberResult><Company>Toll Free</Company><Valid>true</Valid><Use>Assigned to a code holder for normal use.</Use><State>TF</State><RC/><OCN/><OriginalNumber>18006785432</OriginalNumber><CleanNumber>8006785432</CleanNumber><SwitchName/><SwitchType/><Country>United States</Country><CLLI/><PrefixType>Landline</PrefixType><LATA/><sms>Landline</sms><Email/><AssignDate>Unknown</AssignDate><TelecomCity/><TelecomCounty/><TelecomState>TF</TelecomState><TelecomZip/><TimeZone/><Lat/><Long/><Wireless>false</Wireless><LRN/></CheckPhoneNumberResult></CheckPhoneNumberResponse></soap:Body>`;
if response is error {
Expand All @@ -44,7 +45,7 @@ function testSendReceive12() returns error? {
<quer:LicenseKey>0</quer:LicenseKey>
</quer:CheckPhoneNumber>`;

var response = soapClient->sendReceive(body);
xml|mime:Entity[]|error response = check soapClient->sendReceive(body);

xml expected = xml `<soap:Body xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><CheckPhoneNumberResponse xmlns="http://ws.cdyne.com/PhoneVerify/query"><CheckPhoneNumberResult><Company>Toll Free</Company><Valid>true</Valid><Use>Assigned to a code holder for normal use.</Use><State>TF</State><RC/><OCN/><OriginalNumber>18006785432</OriginalNumber><CleanNumber>8006785432</CleanNumber><SwitchName/><SwitchType/><Country>United States</Country><CLLI/><PrefixType>Landline</PrefixType><LATA/><sms>Landline</sms><Email/><AssignDate>Unknown</AssignDate><TelecomCity/><TelecomCounty/><TelecomState>TF</TelecomState><TelecomZip/><TimeZone/><Lat/><Long/><Wireless>false</Wireless><LRN/></CheckPhoneNumberResult></CheckPhoneNumberResponse></soap:Body>`;
if response is error {
Expand All @@ -63,7 +64,7 @@ function testSendOnly11() returns error? {
<quer:LicenseKey>0</quer:LicenseKey>
</quer:CheckPhoneNumber>`;

var response = soapClient->sendOnly(body);
error? response = check soapClient->sendOnly(body);

if response is error {
test:assertFail(msg = response.message());
Expand All @@ -79,7 +80,7 @@ function testSendOnly12() returns error? {
<quer:LicenseKey>0</quer:LicenseKey>
</quer:CheckPhoneNumber>`;

var response = soapClient->sendOnly(body);
error? response = check soapClient->sendOnly(body);

if response is error {
test:assertFail(msg = response.message());
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ downloadPluginVersion=4.0.4
releasePluginVersion=2.6.0
ballerinaGradlePluginVersion=1.0.0

ballerinaLangVersion=2201.8.0-20230726-145300-b2bdf796
ballerinaLangVersion=2201.7.0

#stdlib dependencies
stdlibIoVersion=1.5.0
Expand Down

0 comments on commit c0ceea6

Please sign in to comment.