Merge pull request #5676 from rozagerardo/geroza/BAEL-10301_fix-unit-tests-in-core-java-module
[BAEL-10301] core-java | fix unit tests
This commit is contained in:
commit
b5907e06e7
|
@ -2,6 +2,9 @@ package com.baeldung.abstractclasses;
|
||||||
|
|
||||||
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
|
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
|
||||||
import com.baeldung.abstractclasses.filereaders.LowercaseFileReader;
|
import com.baeldung.abstractclasses.filereaders.LowercaseFileReader;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -10,7 +13,9 @@ public class LowercaseFileReaderUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenLowercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
|
public void givenLowercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
|
||||||
String filePath = getClass().getClassLoader().getResource("files/test.txt").getPath().substring(1);
|
// We'll transform the resource URL path to URI to load the file correctly in Windows
|
||||||
|
URL url = getClass().getClassLoader().getResource("files/test.txt");
|
||||||
|
String filePath = Paths.get(url.toURI()).toString();
|
||||||
BaseFileReader lowercaseFileReader = new LowercaseFileReader(filePath);
|
BaseFileReader lowercaseFileReader = new LowercaseFileReader(filePath);
|
||||||
|
|
||||||
assertThat(lowercaseFileReader.readFile()).isInstanceOf(List.class);
|
assertThat(lowercaseFileReader.readFile()).isInstanceOf(List.class);
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
package com.baeldung.abstractclasses;
|
package com.baeldung.abstractclasses;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
|
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
|
||||||
import com.baeldung.abstractclasses.filereaders.StandardFileReader;
|
import com.baeldung.abstractclasses.filereaders.StandardFileReader;
|
||||||
import java.util.List;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class StandardFileReaderUnitTest {
|
public class StandardFileReaderUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenStandardFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
|
public void givenStandardFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
|
||||||
String filePath = getClass().getClassLoader().getResource("files/test.txt").getPath().substring(1);
|
// We'll transform the resource URL path to URI to load the file correctly in Windows
|
||||||
|
URL url = getClass().getClassLoader().getResource("files/test.txt");
|
||||||
|
String filePath = Paths.get(url.toURI()).toString();
|
||||||
BaseFileReader standardFileReader = new StandardFileReader(filePath);
|
BaseFileReader standardFileReader = new StandardFileReader(filePath);
|
||||||
|
|
||||||
assertThat(standardFileReader.readFile()).isInstanceOf(List.class);
|
assertThat(standardFileReader.readFile()).isInstanceOf(List.class);
|
||||||
|
|
|
@ -2,6 +2,9 @@ package com.baeldung.abstractclasses;
|
||||||
|
|
||||||
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
|
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
|
||||||
import com.baeldung.abstractclasses.filereaders.UppercaseFileReader;
|
import com.baeldung.abstractclasses.filereaders.UppercaseFileReader;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -10,7 +13,9 @@ public class UppercaseFileReaderUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenUppercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
|
public void givenUppercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
|
||||||
String filePath = getClass().getClassLoader().getResource("files/test.txt").getPath().substring(1);
|
// We'll transform the resource URL path to URI to load the file correctly in Windows
|
||||||
|
URL url = getClass().getClassLoader().getResource("files/test.txt");
|
||||||
|
String filePath = Paths.get(url.toURI()).toString();
|
||||||
BaseFileReader uppercaseFileReader = new UppercaseFileReader(filePath);
|
BaseFileReader uppercaseFileReader = new UppercaseFileReader(filePath);
|
||||||
|
|
||||||
assertThat(uppercaseFileReader.readFile()).isInstanceOf(List.class);
|
assertThat(uppercaseFileReader.readFile()).isInstanceOf(List.class);
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class SimpleDateFormatUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenSpecificDate_whenFormattedUsingDateFormat_thenCheckFormatCorrect() throws Exception {
|
public void givenSpecificDate_whenFormattedUsingDateFormat_thenCheckFormatCorrect() throws Exception {
|
||||||
DateFormat formatter = DateFormat.getDateInstance(DateFormat.SHORT);
|
DateFormat formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
|
||||||
assertEquals("5/24/77", formatter.format(new Date(233345223232L)));
|
assertEquals("5/24/77", formatter.format(new Date(233345223232L)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue