2022

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Now we will test the write operation where we take and Array of HelloParameter objects as input and the write operation prints it out 

Panel
Wiki Markup

@Test
public void testWriteHello() {
try {

		HelloWorldSvc svc = new HelloWorldSvc();

		svc.setContext(null);

		svc.open();

		HelloParameter param = new HelloParameter();
		param.name = "Test1";
		param.id = "id1";

		HelloParameter param2 = new HelloParameter();
		param2.name = "Test1";
		param2.id = "id2";

		List<HelloParameter> inputParams = new
	ArrayList<HelloWorldSvc.HelloParameter>();
		svc.writeHello(inputParams);

		svc.close();

	} catch (Exception e) {
		e.printStackTrace();
	}
}
Image Added
So if we analyze the outputs of the read and write test runs, we find that the Read operation prints out the result from the init array which matches the filter by appending the session key

The Write operation reads the input parameter array and prints the input parameter by prepending "Hello" to the name and appending the SessionKey to the same 

Now that we have developed our HelloWorldSvc AppCode implementation it is time to deploy it to DBSync platform and then running a test workfow. 

For your reference the complete code is given below: 

Code Block

 package myappcode.test;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import myappcode.HelloWorldSvc;
import myappcode.HelloWorldSvc.HelloFilter;
import myappcode.HelloWorldSvc.HelloParameter;

import org.apache.tools.ant.taskdefs.Concat;
import org.junit.Test;

import com.appmashups.appcode.Context;

public class TestHelloWorldAppCode {

	//@Test
	public void testOpen() {

		try {

			HelloWorldSvc svc = new HelloWorldSvc();

			svc.setContext(null);

			svc.open();

			svc.close();

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	//@Test
	public void testReadHello() {

		try {

			HelloWorldSvc svc = new HelloWorldSvc();

			svc.setContext(null);

			svc.open();

			HelloFilter filter = new HelloFilter();
			filter.key = "Scott";

			svc.readHello(filter);

			svc.close();

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

		@Test
		public void testWriteHello() {
			try {

				HelloWorldSvc svc = new HelloWorldSvc();

				svc.setContext(null);

				svc.open();

				HelloParameter param = new HelloParameter();
				param.name = "Test1";
				param.id = "id1";

				HelloParameter param2 = new HelloParameter();
				param2.name = "Test1";
				param2.id = "id2";

				List<HelloParameter> inputParams = new
		ArrayList<HelloWorldSvc.HelloParameter>();
				inputParams.add(param);
				inputParams.add(param2);

				svc.writeHello(inputParams);

				svc.close();

			} catch (Exception e) {
				e.printStackTrace();
		}

	}