Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Java Client API
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Genesys PGR
Java Client API
Commits
c7294d17
Commit
c7294d17
authored
May 11, 2017
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remark parser
parent
5abe5f80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
src/main/java/org/genesys2/client/oauth/api/accession/Remark.java
.../java/org/genesys2/client/oauth/api/accession/Remark.java
+24
-0
src/test/java/org/geneys2/client/oauth/RemarkTest.java
src/test/java/org/geneys2/client/oauth/RemarkTest.java
+55
-0
No files found.
src/main/java/org/genesys2/client/oauth/api/accession/Remark.java
View file @
c7294d17
...
...
@@ -16,11 +16,16 @@
package
org.genesys2.client.oauth.api.accession
;
import
java.util.Arrays
;
import
java.util.stream.Collectors
;
/**
* The Class Remark.
*/
public
class
Remark
{
private
static
final
Remark
[]
REMARK_ARRAY
=
new
Remark
[]
{};
/** The field name. */
private
String
fieldName
;
...
...
@@ -63,4 +68,23 @@ public class Remark {
this
.
remark
=
remark
;
}
public
static
Remark
[]
parse
(
String
source
)
{
if
(
source
==
null
||
source
.
trim
().
length
()
==
0
)
return
null
;
Remark
[]
remarks
=
Arrays
.
stream
(
source
.
trim
().
split
(
";"
)).
map
(
r
->
r
.
trim
()).
filter
(
r
->
r
.
length
()
>
0
).
map
(
r
->
{
Remark
remark
=
new
Remark
();
String
[]
s
=
r
.
split
(
":"
,
2
);
if
(
s
.
length
==
1
)
{
remark
.
remark
=
s
[
0
].
trim
();
}
else
{
remark
.
fieldName
=
s
[
0
].
trim
();
remark
.
remark
=
s
[
1
].
trim
();
}
return
remark
;
}).
collect
(
Collectors
.
toList
()).
toArray
(
REMARK_ARRAY
);
return
remarks
.
length
==
0
?
null
:
remarks
;
}
}
src/test/java/org/geneys2/client/oauth/RemarkTest.java
0 → 100644
View file @
c7294d17
/*
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.geneys2.client.oauth
;
import
static
org
.
hamcrest
.
CoreMatchers
.*;
import
static
org
.
hamcrest
.
MatcherAssert
.*;
import
org.genesys2.client.oauth.api.accession.Remark
;
import
org.junit.Test
;
public
class
RemarkTest
{
@Test
public
void
testRemarkParser
()
{
assertThat
(
Remark
.
parse
(
null
),
nullValue
());
assertThat
(
Remark
.
parse
(
""
),
nullValue
());
assertThat
(
Remark
.
parse
(
" "
),
nullValue
());
assertThat
(
Remark
.
parse
(
" ;;"
),
nullValue
());
assertThat
(
Remark
.
parse
(
"Remark"
),
not
(
nullValue
()));
Remark
r
=
Remark
.
parse
(
"FIELD:Remark"
)[
0
];
assertThat
(
r
.
getFieldName
(),
is
(
"FIELD"
));
assertThat
(
r
.
getRemark
(),
is
(
"Remark"
));
r
=
Remark
.
parse
(
"FIELD :Remark"
)[
0
];
assertThat
(
r
.
getFieldName
(),
is
(
"FIELD"
));
assertThat
(
r
.
getRemark
(),
is
(
"Remark"
));
r
=
Remark
.
parse
(
"FIELD: Remark"
)[
0
];
assertThat
(
r
.
getFieldName
(),
is
(
"FIELD"
));
assertThat
(
r
.
getRemark
(),
is
(
"Remark"
));
Remark
[]
rr
=
Remark
.
parse
(
"FIELD: Remark;Test"
);
assertThat
(
rr
.
length
,
is
(
2
));
assertThat
(
rr
[
0
].
getFieldName
(),
is
(
"FIELD"
));
assertThat
(
rr
[
0
].
getRemark
(),
is
(
"Remark"
));
assertThat
(
rr
[
1
].
getFieldName
(),
nullValue
());
assertThat
(
rr
[
1
].
getRemark
(),
is
(
"Test"
));
}
}
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