/* * Test for add(Duration rhs). */ @Test(dataProvider = "duration-for-add") public void checkDurationAdd(String initVal, String addVal, String result) { Duration durationInit = datatypeFactory.newDuration(initVal); Duration durationAdd = datatypeFactory.newDuration(addVal); Duration durationResult = datatypeFactory.newDuration(result); assertEquals(durationInit.add(durationAdd), durationResult); }
/* * Test for add(Duration rhs) 'rhs' is null , should throw NPE. "1 year" + * "-1 day" or "-1 year" + "1 day" should throw IllegalStateException */ @Test( expectedExceptions = {NullPointerException.class, IllegalStateException.class}, dataProvider = "duration-for-addneg") public void checkDurationAddNeg(String initVal, String addVal) { Duration durationInit = datatypeFactory.newDuration(initVal); Duration durationAdd = addVal == null ? null : datatypeFactory.newDuration(addVal); durationInit.add(durationAdd); }