* BAEL-4631

First code example draft

* BAEL-4631

Removed unnecesary constructors
Removed unnecessary comments
Removed unnecessary test

* BAEL-4631

Fixed xml files format

* BAEL-4631

Fixing pom.xml and testng.xml indentation
This commit is contained in:
victorsempere
2022-01-13 00:51:07 +01:00
committed by GitHub
parent 7a5d817a1d
commit 29ebe5e849
5 changed files with 160 additions and 0 deletions
@@ -0,0 +1,11 @@
package com.baeldung.testing_modules.testng_command_line;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateSerializerService {
public String serializeDate(Date date, String format) {
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(date);
}
}
@@ -0,0 +1,23 @@
package com.baeldung.testing_modules.testng_command_line;
import java.util.Date;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(testName = "Date Serializer")
public class DateSerializerServiceUnitTest {
private DateSerializerService toTest;
@BeforeClass
public void beforeClass() {
toTest = new DateSerializerService();
}
@Test(expectedExceptions = { NullPointerException.class })
void givenNullDate_whenSerializeDate_thenThrowsException() {
Date dateToTest = null;
toTest.serializeDate(dateToTest, "yyyy/MM/dd HH:mm:ss.SSS");
}
}