Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synergy-api-util
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Raimbek Egemberdiev
synergy-api-util
Commits
b031bab4
Commit
b031bab4
authored
Nov 29, 2016
by
Raimbek Egemberdiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
удален зависимост на guava, оставлено только для тестов
parent
80327073
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
26 deletions
+68
-26
build.gradle
build.gradle
+2
-2
src/main/java/kz/arta/synergy/api/RestHttpQuery.java
src/main/java/kz/arta/synergy/api/RestHttpQuery.java
+20
-20
src/main/java/kz/arta/synergy/api/asforms/converter/components/AbstractComponentConverter.java
...orms/converter/components/AbstractComponentConverter.java
+1
-1
src/main/java/kz/arta/synergy/api/asforms/converter/components/DateConverter.java
...nergy/api/asforms/converter/components/DateConverter.java
+1
-1
src/main/java/kz/arta/synergy/api/asforms/utils/Strings.java
src/main/java/kz/arta/synergy/api/asforms/utils/Strings.java
+12
-0
src/main/java/kz/arta/synergy/api/dictionaries/DictionaryService.java
...a/kz/arta/synergy/api/dictionaries/DictionaryService.java
+1
-1
src/main/java/kz/arta/synergy/api/dictionaries/pojo/Dictionary.java
...ava/kz/arta/synergy/api/dictionaries/pojo/Dictionary.java
+2
-1
src/test/java/kz/arta/synergy/api/RestHttpQueryTest.java
src/test/java/kz/arta/synergy/api/RestHttpQueryTest.java
+29
-0
No files found.
build.gradle
View file @
b031bab4
group
'kz.arta.synergy.api'
version
'1.
2
'
version
'1.
3
'
apply
plugin:
'java'
apply
plugin:
'artifactory-publish'
...
...
@@ -25,7 +25,7 @@ def jacksonVersion = '1.9.2'
dependencies
{
testCompile
group:
'org.testng'
,
name:
'testng'
,
version:
'6.8'
testCompile
group:
'org.mockito'
,
name:
'mockito-all'
,
version:
'1.10.19'
c
ompile
group:
'com.google.guava'
,
name:
'guava'
,
version:
'19.0'
testC
ompile
group:
'com.google.guava'
,
name:
'guava'
,
version:
'19.0'
compile
(
group:
'org.codehaus.jackson'
,
name:
'jackson-core-asl'
,
version:
jacksonVersion
,
transitive:
false
)
compile
(
group:
'org.codehaus.jackson'
,
name:
'jackson-mapper-asl'
,
version:
jacksonVersion
,
transitive:
false
)
}
...
...
src/main/java/kz/arta/synergy/api/RestHttpQuery.java
View file @
b031bab4
package
kz.arta.synergy.api
;
import
com.google.common.base.Function
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Predicates
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.FluentIterable
;
import
kz.arta.synergy.api.asforms.utils.Strings
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
...
...
@@ -91,23 +87,27 @@ public class RestHttpQuery {
return
query
;
}
p
rivate
String
joinParamsForQuery
(
Map
<
String
,
?>
params
)
{
p
ublic
String
joinParamsForQuery
(
Map
<
String
,
?>
params
)
{
if
(
params
==
null
)
return
""
;
return
FluentIterable
.
from
(
params
.
entrySet
()).
transform
(
new
Function
<
Map
.
Entry
<
String
,
?>,
String
>()
{
@Override
public
String
apply
(
Map
.
Entry
<
String
,
?>
input
)
{
String
value
=
input
.
getValue
().
toString
();
String
result
=
""
;
for
(
Map
.
Entry
<
String
,
?>
param
:
params
.
entrySet
())
{
if
(
param
.
getValue
()
==
null
||
param
.
getValue
().
toString
().
isEmpty
())
{
continue
;
}
String
value
;
try
{
value
=
URLEncoder
.
encode
(
value
,
"UTF-8"
);
value
=
URLEncoder
.
encode
(
String
.
valueOf
(
param
.
getValue
())
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
value
=
null
;
}
if
(
value
==
null
||
value
.
isEmpty
())
return
null
;
return
input
.
getKey
()
+
"="
+
value
;
result
+=
param
.
getKey
()
+
"="
+
value
+
"&"
;
}
}).
filter
(
Predicates
.
notNull
()).
join
(
Joiner
.
on
(
"&"
));
return
result
.
substring
(
0
,
result
.
length
()
-
1
);
}
private
String
readStringReturn
(
HttpURLConnection
conn
)
throws
IOException
{
...
...
src/main/java/kz/arta/synergy/api/asforms/converter/components/AbstractComponentConverter.java
View file @
b031bab4
package
kz.arta.synergy.api.asforms.converter.components
;
import
com.google.common.base.Strings
;
import
kz.arta.synergy.api.asforms.annotations.KeyValue
;
import
kz.arta.synergy.api.asforms.exceptions.UnsupportedFieldTypeException
;
import
kz.arta.synergy.api.asforms.pojo.AsFormData
;
import
kz.arta.synergy.api.asforms.pojo.AsFormDataContainer
;
import
kz.arta.synergy.api.asforms.utils.Strings
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Field
;
...
...
src/main/java/kz/arta/synergy/api/asforms/converter/components/DateConverter.java
View file @
b031bab4
package
kz.arta.synergy.api.asforms.converter.components
;
import
com.google.common.base.Strings
;
import
kz.arta.synergy.api.asforms.annotations.DateCmp
;
import
kz.arta.synergy.api.asforms.pojo.AsFormData
;
import
kz.arta.synergy.api.asforms.pojo.AsFormDataContainer
;
import
kz.arta.synergy.api.asforms.pojo.ComponentTypes
;
import
kz.arta.synergy.api.asforms.utils.Strings
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Field
;
...
...
src/main/java/kz/arta/synergy/api/asforms/utils/Strings.java
0 → 100644
View file @
b031bab4
package
kz.arta.synergy.api.asforms.utils
;
/**
* @author raimbek
* @since 29.11.2016
*/
public
class
Strings
{
public
static
boolean
isNullOrEmpty
(
String
s
)
{
return
s
==
null
||
s
.
length
()
==
0
;
}
}
src/main/java/kz/arta/synergy/api/dictionaries/DictionaryService.java
View file @
b031bab4
package
kz.arta.synergy.api.dictionaries
;
import
com.google.common.base.Strings
;
import
kz.arta.synergy.api.JsonUtils
;
import
kz.arta.synergy.api.Query
;
import
kz.arta.synergy.api.QueryContext
;
import
kz.arta.synergy.api.RestHttpQuery
;
import
kz.arta.synergy.api.asforms.utils.Strings
;
import
kz.arta.synergy.api.dictionaries.annotations.DictionaryCode
;
import
kz.arta.synergy.api.dictionaries.annotations.DictionaryColumn
;
import
kz.arta.synergy.api.dictionaries.pojo.Dictionary
;
...
...
src/main/java/kz/arta/synergy/api/dictionaries/pojo/Dictionary.java
View file @
b031bab4
package
kz.arta.synergy.api.dictionaries.pojo
;
import
com.google.common.base.Strings
;
import
kz.arta.synergy.api.asforms.utils.Strings
;
import
java.util.List
;
...
...
src/test/java/kz/arta/synergy/api/RestHttpQueryTest.java
0 → 100644
View file @
b031bab4
package
kz.arta.synergy.api
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author raimbek
* @since 29.11.2016
*/
public
class
RestHttpQueryTest
{
@Test
public
void
testJoinParamsForQuery
()
throws
Exception
{
RestHttpQuery
restHttpQuery
=
new
RestHttpQuery
(
null
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"one"
,
"value1"
);
params
.
put
(
"two"
,
"value2"
);
params
.
put
(
"null_value"
,
null
);
params
.
put
(
"three"
,
"кирилица с пробелом"
);
String
expected
=
"two=value2&one=value1&three=%D0%BA%D0%B8%D1%80%D0%B8%D0%BB%D0%B8%D1%86%D0%B0+%D1%81+%D0%BF%D1%80%D0%BE%D0%B1%D0%B5%D0%BB%D0%BE%D0%BC"
;
String
result
=
restHttpQuery
.
joinParamsForQuery
(
params
);
Assert
.
assertEquals
(
result
,
expected
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment