I followed the instructions from the video and tried to change the transform message widget for getUnitedFlightsFlow, getAmericanFlightsFlow & getDeltaFlightsFlow from mapping to another json to java. When I try to run the project and test them, I got NullPointerException
...
FULL TEXT IN ATTACHMENT [46785-more.txt]
Janice,
First of all going forward please attach all files necessary to test your solution, for eg: to test your solution, I need not only the implementation xml file, but also global.xml, .properties, .java files etc,. i.e. probably your entire solution in a zipped format to mimic your exact environment. In any case, I ended up creating most of these files and tested your solution.
Here are my findings: In the united flow, your dataweave code is incorrect. It looks like as follows:
payload.flights map ((flight , indexOfFlight) -> {
airlineName: flight.airlineName,
availableSeats: flight.emptySeats,
airline: flight.airlineName,
flightCode: flight.code,
origination: flight.origin,
fromAirportCode: flight.origin,
toAirportCode: flight.destination,
departureDate: flight.departureDate,
destination: flight.destination,
emptySeats: flight.emptySeats,
price: flight.price,
planeType: flight.planeType
} as :object {
class : "com.mulesoft.training.Flight"
})
When you transform your data to produce the result in the form of `com.mulesoft.training.Flight` object, your mappings should use schema as defined by `Flight` class. Please open the `Flight.java` file located in `src/main/java` and observe the schema. The instance variables are defined as follows:
String flightCode;
String origination;
int availableSeats;
String departureDate;
String airlineName;
String destination;
double price;
String planeType
So, the correct dataweave expression for United Flow is as follows:
payload.flights map ((flight , indexOfFlight) -> {
flightCode: flight.code,
origination: flight.origin,
availableSeats: flight.emptySeats,
departureDate: flight.departureDate,
airlineName: flight.airlineName,
destination: flight.destination,
price: flight.price,
planeType: flight.planeType
} as :object {
class : "com.mulesoft.training.Flight"
})
The same way, the correct dataweave expression for Delta Flow is as follows:
payload.ns0# findFlightResponse.*return map ((return , indexOfReturn) -> {
flightCode: return.code,
origination: return.origin,
availableSeats: return.emptySeats,
departureDate: return.departureDate,
airlineName: return.@airlineName,
destination: return.destination,
price: return.price,
planeType: return.planeType
} as :object {
class : "com.mulesoft.training.Flight"
})
Finally, following the same mechanism, try and figure out the mappings for American Flights flow. I will let you do that.
Hope that helps,
-gopal