Skip to content

Commit 29a2ba1

Browse files
authored
Develop (#33)
* #26 #25 * code style fixed (#28) * Feature/http client tests code quilty (#30) * code style fixed * #29 #26 * code-quilty (#32)
1 parent ab30e85 commit 29a2ba1

File tree

10 files changed

+49
-74
lines changed

10 files changed

+49
-74
lines changed

src/main/java/io/github/rhkiswani/javaff/format/DefaultFormatter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@
2323
* @since 0.0.1
2424
* @see io.github.rhkiswani.javaff.format.Formatter
2525
*/
26-
public abstract class DefaultFormatter<IN, OUT> extends Formatter<IN, OUT> {
26+
public abstract class DefaultFormatter<I, O> extends Formatter<I, O> {
2727

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

3030
@Override
31-
protected OUT format(IN in, Object[] params) throws FormatException {
32-
if (in == null){
31+
protected O format(I i, Object[] params) throws FormatException {
32+
if (i == null){
3333
return null;
3434
}
3535
if (!ArraysUtils.isEmpty(params)){
3636
try {
3737
ArraysUtils.replace(params, null, "");
38-
return formatVal(in, params);
38+
return formatVal(i, params);
3939
} catch (FormatException e){
4040
throw e;
4141
} catch (Throwable t ){
4242
throw new FormatException(t.getMessage());
4343
}
4444

4545
}
46-
return formatVal(in, new Object[]{});
46+
return formatVal(i, new Object[]{});
4747
}
4848

4949
}

src/main/java/io/github/rhkiswani/javaff/httpclient/ApacheHttpClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,14 @@ private void setHeaders(HttpRequestBase method, Map<String, String> headers) {
114114

115115
@Override
116116
public String get(String url, Map<String, String> params, Map<String, String> headers) throws HttpClientException {
117+
String urlWithParams = url;
117118
if(params != null){
118-
url += "?";
119+
urlWithParams += "?";
119120
for (String key : params.keySet()) {
120-
url += key + "=" + params.get(key) +"&";
121+
urlWithParams += key + "=" + params.get(key) +"&";
121122
}
122123
}
123-
return doRequest(new HttpGet(url), params, headers);
124+
return doRequest(new HttpGet(urlWithParams), params, headers);
124125
}
125126

126127
@Override

src/main/java/io/github/rhkiswani/javaff/locale/DefaultLocaleWorker.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ class DefaultLocaleWorker extends ValuesHolder<DefaultLocaleWorker> implements L
3838
private Locale locale = Locale.US;
3939
private ResourceBundle bundle = null;
4040

41-
public DefaultLocaleWorker(){
42-
43-
}
4441
@Override
4542
public void setName(String name) {
4643
this.name = name;
@@ -61,17 +58,18 @@ public Locale getLocale() {
6158

6259
@Override
6360
public void setPath(String path) {
64-
if (path == null || path.isEmpty()){
61+
String tmpPath = path;
62+
if (tmpPath == null || tmpPath.isEmpty()){
6563
this.path = "";
6664
return ;
6765
}
68-
if (path.startsWith("/")){
69-
path = path.substring(1);
66+
if (tmpPath.startsWith("/")){
67+
tmpPath = tmpPath.substring(1);
7068
}
71-
if (!path.endsWith("/") && path.length() > 1){
72-
path = path + "/";
69+
if (!tmpPath.endsWith("/") && tmpPath.length() > 1){
70+
tmpPath = tmpPath + "/";
7371
}
74-
this.path = path;
72+
this.path = tmpPath;
7573
}
7674

7775
public String getPath() {

src/test/java/io/github/rhkiswani/javaff/beans/ValuesHolderTest.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,43 +82,43 @@ public void testX() throws Exception {
8282
}
8383

8484
private class ToStringTestClass extends ValuesHolder{
85-
int i = 123123123;
86-
float f = 123123123;
87-
double d = 123123123;
88-
Date date = new Date();
89-
char c = '\n';
90-
long l = 123123123;
91-
String s = "Kiswani";
92-
int[] arr = new int[]{1, 2, 3};
93-
Collection coll = Arrays.asList(arr);
85+
private int i = 123123123;
86+
private float f = 123123123;
87+
private double d = 123123123;
88+
private Date date = new Date();
89+
private char c = '\n';
90+
private long l = 123123123;
91+
private String s = "Kiswani";
92+
private int[] arr = new int[]{1, 2, 3};
93+
private Collection coll = Arrays.asList(arr);
9494
}
9595

9696
private class ToStringTestClassX extends ValuesHolder{
9797
@ToString
98-
int i = 123123123;
98+
private int i = 123123123;
9999
@ToString
100-
float f = 123123123;
101-
double d = 123123123;
100+
private float f = 123123123;
101+
private double d = 123123123;
102102
}
103103

104104
private class ToStringTestClassXX extends ValuesHolder{
105-
int i = 9090909;
105+
private int i = 9090909;
106106
@HashcodeField
107-
float f = 4444111;
108-
double d = 123123123;
107+
private float f = 4444111;
108+
private double d = 123123123;
109109
}
110110

111111
private class ToStringTestClassXXX extends ValuesHolder{
112112
@EqualsField
113-
int i = 10000;
114-
float f = 123123123;
115-
double d = 123123123;
113+
private int i = 10000;
114+
private float f = 123123123;
115+
private double d = 123123123;
116116
}
117117

118118
private class ToStringTestClassXXXX extends ValuesHolder{
119-
int i = 50000;
120-
float f = 123123123;
119+
private int i = 50000;
120+
private float f = 123123123;
121121
@Id
122-
double d = 99900011;
122+
private double d = 99900011;
123123
}
124124
}

src/test/java/io/github/rhkiswani/javaff/detector/ApiMeadataTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ApiMeadataTest {
1212
private ApiMetadata apiMetadata2;
1313

1414
@Before
15-
public void setup(){
15+
public void setUp(){
1616
apiMetadata = new ApiMetadata(null, null, null, null);
1717
apiMetadata2 = JACKSON_API_METADATA;
1818
}

src/test/java/io/github/rhkiswani/javaff/exceptions/ExceptionHandlersFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class ExceptionHandlersFactoryTest {
1919
private ExceptionHandler exceptionHandler ;
2020

2121
@Before
22-
public void setup(){
22+
public void setUp(){
2323
exceptionHandler = new TestExceptionHandler();
2424
}
2525

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
package io.github.rhkiswani.javaff.format;
22

3-
import io.github.rhkiswani.javaff.exceptions.ExceptionHandler;
4-
import io.github.rhkiswani.javaff.exceptions.ExceptionHandlersFactory;
5-
import io.github.rhkiswani.javaff.lang.exceptions.IllegalParamException;
6-
import org.junit.Before;
73
import org.junit.Test;
84

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

117
public class FormatFactoryTest {
128

13-
private ExceptionHandler exceptionHandler ;
14-
15-
@Before
16-
public void setup(){
17-
exceptionHandler = new TestExceptionHandler();
18-
}
19-
209
@Test
2110
public void testRegistry() throws Exception {
2211
assertThat(FormatFactory.instance()).isNotNull();
@@ -31,12 +20,4 @@ protected String formatVal(Character character, Object[] params) {
3120
});
3221
assertThat(FormatFactory.instance().listImplementations().size()).isEqualTo(4);
3322
}
34-
35-
36-
private class TestExceptionHandler implements ExceptionHandler {
37-
@Override
38-
public void handle(Throwable t) {
39-
t.printStackTrace();
40-
}
41-
};
4223
}

src/test/java/io/github/rhkiswani/javaff/http/HttpClientTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
package io.github.rhkiswani.javaff.http;
22

3-
import io.github.rhkiswani.javaff.detector.ApiDetectorUtil;
43
import io.github.rhkiswani.javaff.factory.exceptions.NoImplementationFoundException;
54
import io.github.rhkiswani.javaff.httpclient.ApacheHttpClient;
65
import io.github.rhkiswani.javaff.httpclient.HttpClient;
76
import io.github.rhkiswani.javaff.httpclient.HttpClientFactory;
87
import io.github.rhkiswani.javaff.json.JsonHandler;
98
import io.github.rhkiswani.javaff.json.JsonHandlerFactory;
109
import org.junit.Test;
11-
import org.junit.runner.RunWith;
12-
import org.powermock.api.mockito.PowerMockito;
13-
import org.powermock.core.classloader.annotations.PrepareForTest;
14-
import org.powermock.modules.junit4.PowerMockRunner;
1510

1611
import java.util.HashMap;
1712
import java.util.Map;

src/test/java/io/github/rhkiswani/javaff/http/WebTester.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ private void sendWhatReceived(HttpServletRequest req, HttpServletResponse resp)
8484
}
8585

8686
protected class Response {
87-
String method;
88-
String contentType;
89-
Map<String, String> params = new HashMap<>();
90-
Map<String, String> requestHeaders = new HashMap<>();
91-
public String jsonParams = "";
87+
protected String method;
88+
protected String contentType;
89+
protected Map<String, String> params = new HashMap<>();
90+
protected Map<String, String> requestHeaders = new HashMap<>();
91+
protected String jsonParams = "";
9292
}
9393
}

tools/deploy.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/usr/bin/env bash
22

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

10-
if [[ $MVN_VERSION == *"SNAPSHOT"* ]]
10+
if [[ $mvn_version == *"SNAPSHOT"* ]]
1111
then
12-
for EACH in `echo "$MVN_VERSION" | grep -o -e "[^-SNAPSHOT]*"`; do
13-
version="$EACH";
12+
for str in $(echo "$mvn_version" | grep -o -e "[^-SNAPSHOT]*"); do
13+
version="$str";
1414
done
1515
fi
1616
}

0 commit comments

Comments
 (0)