Skip to Content
0

Standalone testing Parameterized Mapping

Mar 17, 2017 at 02:52 PM

121

avatar image

Hi SDNites,

I have created a JAVA mapping which is capable to read parameters and is working fine. But during the build I have come across certain issues and would have been resolved quicker if I have the way to test parameterized JAVA mapping standalone. Can you please guide me how can that be achieved.

Regards,

Abhi

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Evgeniy Kolmakov Mar 17, 2017 at 04:50 PM
0

Hi Abhishek!

The common approach is to use separate method to execute main mapping logic and call it from your "transform" method.

You use some class variables to store values you get from input parameters.

So you can assign these variables directly when you test your class localy using "main()" method of the class.

Regards, Evgeniy.

Share
10 |10000 characters needed characters left characters exceeded
Abhishek Gupta Mar 17, 2017 at 08:40 PM
0

Hi Evgeniy,

Thanks for your response.

Can you please explain this and if possible can you share an example,

"You use some class variables to store values you get from input parameters."

I have used methods like getInputParameters to read parameters.

Regards,

Abhi

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Abhishek!

You define class variables like:

public class MyClass extends AbstractTransformation {
private String docType = null;
public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException {
docType = (String)in.getInputParameters.getValue("DOC_TYPE");
...
executeMapping(in.getInputPayload.getInputStream, out.getOutputPayload.getOutputStream);

And when you test your class in NWDS you use main() method like:

public static void main(String[] args) {
MyClass transformer = new MyClass();
transformer.docType = "acc";
try {
InputStream in = new FileInputStream("C:\\in.xml");
OutputStream out = new FileOutputStream("C:\\out.xml");
transformer.executeMapping(in, out);
out.close();
} catch (Exception e) {
e.printStackTrace(); }
}

Regards, Evgeniy.

0
avatar image
Former Member Mar 19, 2017 at 08:06 PM
0

Hi Abhishek,

Find a code sample for testing Java Mapping with input parameters and dynamic values in NetWeaver Developer Studio

https://blogs.sap.com/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio/

Regards

Stefan

Share
10 |10000 characters needed characters left characters exceeded