From d0c4bc53e772023f3744c58aa0da90aa7870756c Mon Sep 17 00:00:00 2001 From: "Haig (Hike) Hovsepian" Date: Wed, 13 Dec 2023 13:33:48 -0600 Subject: [PATCH] feat(fuel)!: Fuel data types from primitives to objects This is the change to update the data types is fuel endpoint to allow nulls when one or two of the fuel signals is empty. This change might break the customers when one of the signals return null from the Smartcar API server. Customer need to be aware to map correctly the null cases. --- src/main/java/com/smartcar/sdk/data/VehicleFuel.java | 12 ++++++------ src/test/java/com/smartcar/sdk/VehicleTest.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/smartcar/sdk/data/VehicleFuel.java b/src/main/java/com/smartcar/sdk/data/VehicleFuel.java index 1b127c2b..5f56db49 100644 --- a/src/main/java/com/smartcar/sdk/data/VehicleFuel.java +++ b/src/main/java/com/smartcar/sdk/data/VehicleFuel.java @@ -2,16 +2,16 @@ /** POJO for Smartcar /fuel endpoint */ public class VehicleFuel extends ApiData { - private double range; - private double percentRemaining; - private double amountRemaining; + private Double range; + private Double percentRemaining; + private Double amountRemaining; /** * Returns the fuel range * * @return fuel range */ - public double getRange() { + public Double getRange() { return this.range; } @@ -20,7 +20,7 @@ public double getRange() { * * @return fuel percent remaining */ - public double getPercentRemaining() { + public Double getPercentRemaining() { return this.percentRemaining; } @@ -29,7 +29,7 @@ public double getPercentRemaining() { * * @return fuel amount remaining */ - public double getAmountRemaining() { + public Double getAmountRemaining() { return this.amountRemaining; } diff --git a/src/test/java/com/smartcar/sdk/VehicleTest.java b/src/test/java/com/smartcar/sdk/VehicleTest.java index 79f7ce4c..34ab9643 100644 --- a/src/test/java/com/smartcar/sdk/VehicleTest.java +++ b/src/test/java/com/smartcar/sdk/VehicleTest.java @@ -169,9 +169,9 @@ public void testFuel() throws Exception { VehicleFuel fuel = this.subject.fuel(); - Assert.assertEquals(fuel.getAmountRemaining(), 53.2); - Assert.assertEquals(fuel.getPercentRemaining(), 0.3); - Assert.assertEquals(fuel.getRange(), 40.5); + Assert.assertEquals(fuel.getAmountRemaining(), Double.valueOf(53.2)); + Assert.assertEquals(fuel.getPercentRemaining(), Double.valueOf(0.3)); + Assert.assertEquals(fuel.getRange(), Double.valueOf(40.5)); } @Test