Custom Assertions in Java

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
Hello Everyone,

Below is an example of a Java script that can be used as a custom assertion in an assertor tool in SOAtest. This script gets a value from a data source, prints that value along with the response value, and returns a boolean value based on whether or not the response value contains the data source value.

package examples;

import com.parasoft.api.*;

public class Comparison {

//Compares a value from a database data source to a value returned in a SOAP response
public boolean compareToDatabase(Object input, ScriptingContext context)
throws {

//Gets values from database data source named "Books"
String value = context.getValue("Books", "Book");

//Prints database data source values along with SOAP response values in a message to the console
Application.showMessage("Value from database is " + value + ".\nValue from SOAP response is " + input.toString() + ".");

//Verifies that the SOAP response value contains the database data source value
return input.toString().contains(value);



Sign In or Register to comment.