Added junit intigration and fixed issues iwth object mapper

This commit is contained in:
Isaac Parenteau
2019-07-21 11:52:25 -05:00
parent 0c3739c8db
commit 79f913cc6d
4 changed files with 11 additions and 19 deletions

View File

@ -31,10 +31,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -88,6 +88,9 @@ public class ObjectMapperHelper {
*/
public static <T> ObjectMapperResults<T> readValue(Object src, Class<T> clazz) {
try {
if (src instanceof String) {
return readValue((String)src, clazz);
}
return readValue(mapper.writeValueAsString(src), clazz);
} catch (Exception ex) {
return new ObjectMapperResults<T>(ex);
@ -116,6 +119,9 @@ public class ObjectMapperHelper {
*/
public static <T, L extends Collection<?>> ObjectMapperListResults<List<T>> readListValue(Object object, Class<T> objectClass, Class<L> listClass) {
try {
if (object instanceof String) {
return readListValue((String)object, objectClass, listClass);
}
return readListValue(mapper.writeValueAsString(object), objectClass, listClass);
} catch (Exception ex) {
return new ObjectMapperListResults<>(ex);

View File

@ -4,7 +4,6 @@ import static net.locusworks.common.Charsets.UTF_8;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
@ -84,12 +83,8 @@ public class FileReader implements AutoCloseableIterator<FileReader.LineInfo>, I
throw new IllegalArgumentException("Unable to find resource with name of" + fileName);
}
//Call the buffered reader initializer once the file is found
try(BufferedReader br = new BufferedReader(new InputStreamReader(is, UTF_8))) {
BufferedReader br = new BufferedReader(new InputStreamReader(is, UTF_8));
init(br);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
/**
@ -100,7 +95,8 @@ public class FileReader implements AutoCloseableIterator<FileReader.LineInfo>, I
if (file == null) throw new IllegalArgumentException("File cannot be null");
if (Files.notExists(file)) throw new IllegalArgumentException("File " + file + " does not exist");
if (!Files.isRegularFile(file)) throw new IllegalArgumentException("File " + file + " is not a file");
try (BufferedReader br = Files.newBufferedReader(file)) {
try {
BufferedReader br = Files.newBufferedReader(file);
init(br);
} catch (Exception ex) {
throw new RuntimeException(ex);

View File

@ -1,6 +0,0 @@
#test propertis
#Fri Feb 16 09:42:40 EST 2018
logLevel=INFO
dbPort=3306
userExpirationDays=3650
dbHost=localhost