Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,27 @@ private String formatDate(String ETD) {
* @return faFlightID
* @throws IOException IOException
*/
private JsonNode parseFaFlightIDFromJson(String json, String date) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(json);
JsonNode flights = rootNode.get("FlightInfoStatusResult").get("flights");

if (flights.isArray()) {
for (final JsonNode objNode : flights) {
JsonNode faFlightID = objNode.get("faFlightID");
JsonNode filedDepartureTimeNode = objNode.get("filed_departure_time");
String filedDepartureDate = filedDepartureTimeNode.get("date").asText();
if (date.equals(filedDepartureDate)) {
return objNode;
}
}
}
return null;
}
private JsonNode parseFaFlightIDFromJson(String json, String date) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(json);
JsonNode flightInfoStatus = rootNode.get("FlightInfoStatusResult");
if (flightInfoStatus == null) {
return null;
}
JsonNode flights = flightInfoStatus.get("flights");

if (flights != null && flights.isArray()) {
for (final JsonNode objNode : flights) {
JsonNode faFlightID = objNode.get("faFlightID");
JsonNode filedDepartureTimeNode = objNode.get("filed_departure_time");
String filedDepartureDate = filedDepartureTimeNode.get("date").asText();
if (date.equals(filedDepartureDate)) {
return objNode;
}
}
}
return null;
}

/**
* Method that retrieves flight tracks for a flight
Expand Down
2 changes: 1 addition & 1 deletion API/code/restapi/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ marinetraffic.api.param.protocol.value=jsono
marinetraffic.api.param.timespan.value=240
# MMSI value for test purposes
marinetraffic.api.test.mmsi.value=310627000

logging.level.root=DEBUG
Binary file added API/docs/images/debug_logs.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/docs/images/no_flight_data.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added API/docs/images/npe_fix.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"info": {
"_postman_id": "83b6c426-6768-4287-ba5b-d7f7fe020d4f",
"name": "F2F-BugFix of get flight status latest data",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Get flight details by shipment number (200)",
"request": {
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "http://localhost:8080/v1/flight/PNH015420",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"v1",
"flight",
"PNH015420"
]
}
},
"response": []
}
]
}
60 changes: 60 additions & 0 deletions API/docs/validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Panalpina Bugfix#1 verfiication

The fix is only for backend the verification document explains only aboout how to verify the backend service.


#Apply patch

Skip this test if already done.

git am > 0001-commit-for-BugFix-1-challenge.patch

#Setup backend:

update the below properties in application.properties.

fxml3.username=UCtURaPR
fxml3.password=9d1f7723d5165ac5d9151c8b966176982aea8eca
fxml3.url.prefix=https://flightxml.flightaware.com/json/FlightXML3/

setup the backend document by following the steps in $cd API/docs/README.md file.


#Bug 1:

By looking at the stacktrace, there is a mismatch in the response json. I fixed by checking for the not null condition.

Import the $cd API/docs/postman/F2F-BugFix of get flight status latest data.postman_collection into postman.

Execute the Get flight details by shipment number (200) with any value parameter by replacing the value with `PNH015420`. You will get the result.

Please refer the screenshots.


![npe+fix](./images/npe_fix.png)


![no_flight_data_in_api](./images/no_flight_data.png)



#Bug 2:

The debug log is enabled. Refer the screenshot.


![degug_logs](./images/debug_logs.png)

#Bug 3:

By looking at the console of browser, the error is because of max request limit reached. There is no code fix required. It has to do with business deciding on the maximum request can be buy from google maps.

You have exceeded your request quota for this API. See https://developers.google.com/maps/documentation/javascript/error-messages?utm_source=maps_js&utm_medium=degraded&utm_campaign=billing#api-key-and-billing-errors