Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@
* @since 0.0.1
* @see io.github.rhkiswani.javaff.format.Formatter
*/
public abstract class DefaultFormatter<IN, OUT> extends Formatter<IN, OUT> {
public abstract class DefaultFormatter<I, O> extends Formatter<I, O> {

protected abstract OUT formatVal(IN in, Object[] params);
protected abstract O formatVal(I i, Object[] params);

@Override
protected OUT format(IN in, Object[] params) throws FormatException {
if (in == null){
protected O format(I i, Object[] params) throws FormatException {
if (i == null){
return null;
}
if (!ArraysUtils.isEmpty(params)){
try {
ArraysUtils.replace(params, null, "");
return formatVal(in, params);
return formatVal(i, params);
} catch (FormatException e){
throw e;
} catch (Throwable t ){
throw new FormatException(t.getMessage());
}

}
return formatVal(in, new Object[]{});
return formatVal(i, new Object[]{});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ private void setHeaders(HttpRequestBase method, Map<String, String> headers) {

@Override
public String get(String url, Map<String, String> params, Map<String, String> headers) throws HttpClientException {
String urlWithParams = url;
if(params != null){
url += "?";
urlWithParams += "?";
for (String key : params.keySet()) {
url += key + "=" + params.get(key) +"&";
urlWithParams += key + "=" + params.get(key) +"&";
}
}
return doRequest(new HttpGet(url), params, headers);
return doRequest(new HttpGet(urlWithParams), params, headers);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class DefaultLocaleWorker extends ValuesHolder<DefaultLocaleWorker> implements L
private Locale locale = Locale.US;
private ResourceBundle bundle = null;

public DefaultLocaleWorker(){

}
@Override
public void setName(String name) {
this.name = name;
Expand All @@ -61,17 +58,18 @@ public Locale getLocale() {

@Override
public void setPath(String path) {
if (path == null || path.isEmpty()){
String tmpPath = path;
if (tmpPath == null || tmpPath.isEmpty()){
this.path = "";
return ;
}
if (path.startsWith("/")){
path = path.substring(1);
if (tmpPath.startsWith("/")){
tmpPath = tmpPath.substring(1);
}
if (!path.endsWith("/") && path.length() > 1){
path = path + "/";
if (!tmpPath.endsWith("/") && tmpPath.length() > 1){
tmpPath = tmpPath + "/";
}
this.path = path;
this.path = tmpPath;
}

public String getPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,43 +82,43 @@ public void testX() throws Exception {
}

private class ToStringTestClass extends ValuesHolder{
int i = 123123123;
float f = 123123123;
double d = 123123123;
Date date = new Date();
char c = '\n';
long l = 123123123;
String s = "Kiswani";
int[] arr = new int[]{1, 2, 3};
Collection coll = Arrays.asList(arr);
private int i = 123123123;
private float f = 123123123;
private double d = 123123123;
private Date date = new Date();
private char c = '\n';
private long l = 123123123;
private String s = "Kiswani";
private int[] arr = new int[]{1, 2, 3};
private Collection coll = Arrays.asList(arr);
}

private class ToStringTestClassX extends ValuesHolder{
@ToString
int i = 123123123;
private int i = 123123123;
@ToString
float f = 123123123;
double d = 123123123;
private float f = 123123123;
private double d = 123123123;
}

private class ToStringTestClassXX extends ValuesHolder{
int i = 9090909;
private int i = 9090909;
@HashcodeField
float f = 4444111;
double d = 123123123;
private float f = 4444111;
private double d = 123123123;
}

private class ToStringTestClassXXX extends ValuesHolder{
@EqualsField
int i = 10000;
float f = 123123123;
double d = 123123123;
private int i = 10000;
private float f = 123123123;
private double d = 123123123;
}

private class ToStringTestClassXXXX extends ValuesHolder{
int i = 50000;
float f = 123123123;
private int i = 50000;
private float f = 123123123;
@Id
double d = 99900011;
private double d = 99900011;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ApiMeadataTest {
private ApiMetadata apiMetadata2;

@Before
public void setup(){
public void setUp(){
apiMetadata = new ApiMetadata(null, null, null, null);
apiMetadata2 = JACKSON_API_METADATA;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ExceptionHandlersFactoryTest {
private ExceptionHandler exceptionHandler ;

@Before
public void setup(){
public void setUp(){
exceptionHandler = new TestExceptionHandler();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
package io.github.rhkiswani.javaff.format;

import io.github.rhkiswani.javaff.exceptions.ExceptionHandler;
import io.github.rhkiswani.javaff.exceptions.ExceptionHandlersFactory;
import io.github.rhkiswani.javaff.lang.exceptions.IllegalParamException;
import org.junit.Before;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class FormatFactoryTest {

private ExceptionHandler exceptionHandler ;

@Before
public void setup(){
exceptionHandler = new TestExceptionHandler();
}

@Test
public void testRegistry() throws Exception {
assertThat(FormatFactory.instance()).isNotNull();
Expand All @@ -31,12 +20,4 @@ protected String formatVal(Character character, Object[] params) {
});
assertThat(FormatFactory.instance().listImplementations().size()).isEqualTo(4);
}


private class TestExceptionHandler implements ExceptionHandler {
@Override
public void handle(Throwable t) {
t.printStackTrace();
}
};
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package io.github.rhkiswani.javaff.http;

import io.github.rhkiswani.javaff.detector.ApiDetectorUtil;
import io.github.rhkiswani.javaff.factory.exceptions.NoImplementationFoundException;
import io.github.rhkiswani.javaff.httpclient.ApacheHttpClient;
import io.github.rhkiswani.javaff.httpclient.HttpClient;
import io.github.rhkiswani.javaff.httpclient.HttpClientFactory;
import io.github.rhkiswani.javaff.json.JsonHandler;
import io.github.rhkiswani.javaff.json.JsonHandlerFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.HashMap;
import java.util.Map;
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/io/github/rhkiswani/javaff/http/WebTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ private void sendWhatReceived(HttpServletRequest req, HttpServletResponse resp)
}

protected class Response {
String method;
String contentType;
Map<String, String> params = new HashMap<>();
Map<String, String> requestHeaders = new HashMap<>();
public String jsonParams = "";
protected String method;
protected String contentType;
protected Map<String, String> params = new HashMap<>();
protected Map<String, String> requestHeaders = new HashMap<>();
protected String jsonParams = "";
}
}
8 changes: 4 additions & 4 deletions tools/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env bash

function getVersion(){
MVN_VERSION=$(mvn -q \
mvn_version=$(mvn -q \
-Dexec.executable="echo" \
-Dexec.args='${project.version}' \
--non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)

if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
if [[ $mvn_version == *"SNAPSHOT"* ]]
then
for EACH in `echo "$MVN_VERSION" | grep -o -e "[^-SNAPSHOT]*"`; do
version="$EACH";
for str in $(echo "$mvn_version" | grep -o -e "[^-SNAPSHOT]*"); do
version="$str";
done
fi
}
Expand Down