From 40e4cb6b93716b62939e8bc1e7972bea527c0c0b Mon Sep 17 00:00:00 2001 From: hhimanshu Date: Wed, 20 May 2020 18:09:14 -0700 Subject: [PATCH] Update m4_03_testMortgageConstructorAndCorrectness --- src/test/java/com/h2/Module04_Test.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/h2/Module04_Test.java b/src/test/java/com/h2/Module04_Test.java index 535165e6a..1320b1b27 100644 --- a/src/test/java/com/h2/Module04_Test.java +++ b/src/test/java/com/h2/Module04_Test.java @@ -119,12 +119,16 @@ public void m4_03_testMortgageConstructorAndCorrectness() throws IllegalAccessEx final Field[] fields = mortgageCalculator.getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); - if (field.getName().equals("loanAmount")) { - assertEquals(loanAmount, (long) field.get(instance), "loanAmount should have value of " + loanAmount); - } else if (field.getName().equals("termInYears")) { - assertEquals(termInYears, (int) field.get(instance), "termInYears should have value of " + termInYears); - } else if (field.getName().equals("annualRate")) { - assertEquals(annualRate, (float) field.get(instance), "annualRate should have value of " + annualRate); + switch (field.getName()) { + case "loanAmount": + assertEquals(loanAmount, (long) field.get(instance), "loanAmount should have value of " + loanAmount); + break; + case "termInYears": + assertEquals(termInYears, (int) field.get(instance), "termInYears should have value of " + termInYears); + break; + case "annualRate": + assertEquals(annualRate, (float) field.get(instance), "annualRate should have value of " + annualRate); + break; } }