BAEL-4631 (#11644)
* 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:
+11
@@ -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);
|
||||
}
|
||||
}
|
||||
+23
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user