Skip to Content

Standalone testing Parameterized Mapping

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Mar 17, 2017 at 04:50 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 17, 2017 at 08:40 PM

    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

    Add comment
    10|10000 characters needed 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.

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

    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

    Add comment
    10|10000 characters needed characters exceeded