|
| 1 | +package com.intuit.payment.data; |
| 2 | + |
| 3 | +import org.apache.commons.lang.builder.ReflectionToStringBuilder; |
| 4 | +import org.testng.Assert; |
| 5 | +import org.testng.annotations.BeforeMethod; |
| 6 | +import org.testng.annotations.BeforeTest; |
| 7 | +import org.testng.annotations.Test; |
| 8 | + |
| 9 | +import java.math.BigDecimal; |
| 10 | +import java.util.Date; |
| 11 | + |
| 12 | +/** |
| 13 | + * @author pwaral |
| 14 | + */ |
| 15 | +public class LodgingTest { |
| 16 | + |
| 17 | + |
| 18 | + private String folioID; |
| 19 | + private String chargeType; |
| 20 | + private Date checkInDate; |
| 21 | + private Date checkOutDate; |
| 22 | + private String lengthOfStay; |
| 23 | + private BigDecimal roomRate; |
| 24 | + private String[] extraCharges; |
| 25 | + private String specialProgram; |
| 26 | + private BigDecimal totalAuthAmount; |
| 27 | + |
| 28 | + private Lodging lodging; |
| 29 | + |
| 30 | + |
| 31 | + @BeforeTest |
| 32 | + public void init() { |
| 33 | + folioID = "456"; |
| 34 | + chargeType = "charge type"; |
| 35 | + checkInDate = new Date(10/29/2019); |
| 36 | + checkOutDate = new Date(10/302019); |
| 37 | + lengthOfStay = "15"; |
| 38 | + roomRate = new BigDecimal(245.65); |
| 39 | + extraCharges = new String[]{"34", "45", "55"}; |
| 40 | + specialProgram = "monthly"; |
| 41 | + totalAuthAmount = new BigDecimal(56.34); |
| 42 | + } |
| 43 | + |
| 44 | + @BeforeMethod |
| 45 | + public void setUp() { |
| 46 | + lodging = new Lodging.Builder() |
| 47 | + .folioID(folioID) |
| 48 | + .chargeType(chargeType) |
| 49 | + .checkInDate(checkInDate) |
| 50 | + .checkOutDate(checkOutDate) |
| 51 | + .lengthOfStay(lengthOfStay) |
| 52 | + .roomRate(roomRate) |
| 53 | + .extraCharges(extraCharges) |
| 54 | + .specialProgram(specialProgram) |
| 55 | + .totalAuthAmount(totalAuthAmount) |
| 56 | + .build(); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void testAllGetters() { |
| 61 | + Assert.assertEquals(lodging.getFolioID(), folioID); |
| 62 | + Assert.assertEquals(lodging.getChargeType(), chargeType); |
| 63 | + Assert.assertEquals(lodging.getCheckInDate(), checkInDate); |
| 64 | + Assert.assertEquals(lodging.getLengthOfStay(), lengthOfStay); |
| 65 | + Assert.assertEquals(lodging.getRoomRate(), roomRate); |
| 66 | + Assert.assertEquals(lodging.getExtraCharges(), extraCharges); |
| 67 | + Assert.assertEquals(lodging.getSpecialProgram(), specialProgram); |
| 68 | + Assert.assertEquals(lodging.getTotalAuthAmount(), totalAuthAmount); |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + public void testAllSetters() { |
| 73 | + String updatedFolioID = "123"; |
| 74 | + String udpatedChargeType = "new charge type"; |
| 75 | + Date udpatedCheckInDate = new Date(10/28/2019); |
| 76 | + Date udpatedCheckOutDate = new Date(11/27/2019); |
| 77 | + String udpatedLengthOfStay = "12"; |
| 78 | + BigDecimal udpatedRoomRate = new BigDecimal(34.12); |
| 79 | + String[] udpatedExtraCharges = new String[]{"12", "76","78"}; |
| 80 | + String udpatedSpecialProgram = "annual"; |
| 81 | + BigDecimal udpatedTotalAuthAmount = new BigDecimal(1000.23); |
| 82 | + |
| 83 | + lodging.setFolioID(updatedFolioID); |
| 84 | + lodging.setChargeType(udpatedChargeType); |
| 85 | + lodging.setCheckInDate(udpatedCheckInDate); |
| 86 | + lodging.setCheckOutDate(udpatedCheckOutDate); |
| 87 | + lodging.setLengthOfStay(udpatedLengthOfStay); |
| 88 | + lodging.setRoomRate(udpatedRoomRate); |
| 89 | + lodging.setExtraCharges(udpatedExtraCharges); |
| 90 | + lodging.setSpecialProgram(udpatedSpecialProgram); |
| 91 | + lodging.setTotalAuthAmount(udpatedTotalAuthAmount); |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + Assert.assertEquals(lodging.getFolioID(), updatedFolioID); |
| 96 | + Assert.assertEquals(lodging.getChargeType(), udpatedChargeType); |
| 97 | + Assert.assertEquals(lodging.getCheckInDate(), udpatedCheckInDate); |
| 98 | + Assert.assertEquals(lodging.getCheckOutDate(), udpatedCheckOutDate); |
| 99 | + Assert.assertEquals(lodging.getLengthOfStay(), udpatedLengthOfStay); |
| 100 | + Assert.assertEquals(lodging.getRoomRate(), udpatedRoomRate); |
| 101 | + Assert.assertEquals(lodging.getExtraCharges(), udpatedExtraCharges); |
| 102 | + Assert.assertEquals(lodging.getSpecialProgram(),udpatedSpecialProgram); |
| 103 | + Assert.assertEquals(lodging.getTotalAuthAmount(), udpatedTotalAuthAmount); |
| 104 | + } |
| 105 | + |
| 106 | + @Test |
| 107 | + public void testToString() { |
| 108 | + String expectedResult = ReflectionToStringBuilder.toString(lodging); |
| 109 | + String actualResult = lodging.toString(); |
| 110 | + Assert.assertTrue(actualResult.contains(expectedResult)); |
| 111 | + } |
| 112 | +} |
0 commit comments