BAEL-2312 - Abstract Classes in Java (#5704)

* Initial Commit

* Fixed project files

* Update UppercaseFileReaderUnitTest.java

* Update UppercaseFileReaderUnitTest.java

* Refactored File Reader SubClasses

* Update UppercaseFileReaderUnitTest.java
This commit is contained in:
Alejandro Gervasio
2018-11-18 12:54:57 -03:00
committed by KevinGilmore
parent b4a830475c
commit 86184f8270
8 changed files with 48 additions and 103 deletions
@@ -1,25 +0,0 @@
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.StandardFileReader;
public class StandardFileReaderUnitTest {
@Test
public void givenStandardFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
// 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);
assertThat(standardFileReader.readFile()).isInstanceOf(List.class);
}
}
@@ -1,23 +1,20 @@
package com.baeldung.abstractclasses;
package com.baeldung.abstractclasses.test;
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
import com.baeldung.abstractclasses.filereaders.LowercaseFileReader;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
public class LowercaseFileReaderUnitTest {
@Test
public void givenLowercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
// 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);
Path path = Paths.get(getClass().getClassLoader().getResource("files/test.txt").toURI());
BaseFileReader lowercaseFileReader = new LowercaseFileReader(path);
assertThat(lowercaseFileReader.readFile()).isInstanceOf(List.class);
}
}
@@ -1,9 +1,8 @@
package com.baeldung.abstractclasses;
package com.baeldung.abstractclasses.test;
import com.baeldung.abstractclasses.filereaders.BaseFileReader;
import com.baeldung.abstractclasses.filereaders.UppercaseFileReader;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
@@ -13,11 +12,9 @@ public class UppercaseFileReaderUnitTest {
@Test
public void givenUppercaseFileReaderInstance_whenCalledreadFile_thenCorrect() throws Exception {
// 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);
Path path = Paths.get(getClass().getClassLoader().getResource("files/test.txt").toURI());
BaseFileReader uppercaseFileReader = new UppercaseFileReader(path);
assertThat(uppercaseFileReader.readFile()).isInstanceOf(List.class);
}
}
}