Git Product home page Git Product logo

Comments (1)

cjmamo avatar cjmamo commented on July 20, 2024

Based on the result, without a JavaBean, it does not work.

It does not work because the FreeMarker template is referencing the JavaBean properties. Currently you have this template:

{
  "orderNumber":${order.number},
  "orderStatus":"${order.status}",
  "creationDate":"${order.creationDate?date?string('yyyy-MM-dd')}"
} 

But the above template is referencing JavaBean properties, while in your testJ2JWithoutJb test, you must use a different template that references the JSON keys like the one below:

{
  "orderNumber":${order.order_number},
  "orderStatus":"${order.order_status}",
  "creationDate":"${order.creation_date}"
}

Additionally, to conserve memory, Smooks doesn't retain the child events of the selected parent event unless explicitly configured to do so. In other words, the test will still fail because the child events (e.g., order_number) of the selected event (i.e., order) are discarded. There are couple ways of retaining the child events. Naively, you could retain all the events in memory like this:

@Test
public void testJ2JWithoutJb() throws Exception {
   ...
   smooks.setFilterSettings(FilterSettings.newSaxNgSettings().setMaxNodeDepth(0));
   ...

This way of retaining events can be very inefficient because setting the max node depth to 0 means that all generated events are kept in memory. The Smook fundamentals and templating sections of the docs can guide you in implementing your solution the right way.

from smooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.