Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BraillePlot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Graßnick
BraillePlot
Commits
60cb6153
Commit
60cb6153
authored
5 years ago
by
Leonard Kupper
Browse files
Options
Downloads
Patches
Plain Diff
Update tests to work with required options.
parent
6a52ab9d
No related branches found
No related tags found
1 merge request
!39
App restructuring
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParserTest.java
+23
-12
23 additions, 12 deletions
...nf/mci/brailleplot/commandline/CommandLineParserTest.java
with
23 additions
and
12 deletions
src/test/java/de/tudresden/inf/mci/brailleplot/commandline/CommandLineParserTest.java
+
23
−
12
View file @
60cb6153
package
de.tudresden.inf.mci.brailleplot.commandline
;
import
org.apache.commons.cli.MissingOptionException
;
import
org.apache.commons.cli.ParseException
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -16,7 +18,7 @@ class CommandLineParserTest {
@Test
void
testParseLegalArgs
()
{
String
[]
args
=
{
"-h
"
,
"--csv-path"
,
"foobar"
,
"-p"
,
"test"
,
"-t"
,
"title"
,
"-x"
,
"x-axis"
,
"-y"
,
"y-axis"
,
"-d"
,
"BarChart"
};
String
[]
args
=
{
"-h"
,
"--csv-path"
,
"foobar"
,
"-p"
,
"test"
,
"-t"
,
"title"
,
"-x"
,
"x-axis"
,
"-y"
,
"y-axis"
,
"-d"
,
"BarChart"
};
Assertions
.
assertDoesNotThrow
(()
->
{
commandLineParser
.
parse
(
args
);});
}
...
...
@@ -29,12 +31,13 @@ class CommandLineParserTest {
@Test
void
testEmptyArgs
()
{
String
[]
args
=
{
""
};
Assertions
.
assert
DoesNotThrow
(
()
->
{
commandLineParser
.
parse
(
args
);});
Assertions
.
assert
Throws
(
ParsingException
.
class
,
()
->
{
commandLineParser
.
parse
(
args
);});
}
@Test
void
testBoolFlagRecognized
()
{
String
[]
args
=
{
"-h"
};
final
String
param
=
"xyz"
;
String
[]
args
=
{
"--csv-path"
,
param
,
"-p"
,
param
,
"-t"
,
param
,
"-x"
,
param
,
"-y"
,
param
,
"-d"
,
param
,
"-i"
};
SettingsReader
settings
;
try
{
settings
=
commandLineParser
.
parse
(
args
);
...
...
@@ -42,14 +45,15 @@ class CommandLineParserTest {
fail
();
return
;
// Never executed, satisfy compiler
}
Optional
<
Boolean
>
flag
=
settings
.
isTrue
(
SettingType
.
DISPLAY_HELP
);
Optional
<
Boolean
>
flag
=
settings
.
isTrue
(
SettingType
.
INHIBIT_PRINT
);
Assertions
.
assertTrue
(
flag
.
isPresent
());
Assertions
.
assertTrue
(
flag
.
get
());
}
@Test
void
testBoolFlagCorrectlyNotRecognized
()
{
String
[]
args
=
{
""
};
final
String
param
=
"xyz"
;
String
[]
args
=
{
"--csv-path"
,
param
,
"-p"
,
param
,
"-t"
,
param
,
"-x"
,
param
,
"-y"
,
param
,
"-d"
,
param
};
SettingsReader
settings
;
try
{
settings
=
commandLineParser
.
parse
(
args
);
...
...
@@ -57,14 +61,14 @@ class CommandLineParserTest {
fail
();
return
;
// Never executed, satisfy compiler
}
Optional
<
Boolean
>
flag
=
settings
.
isTrue
(
SettingType
.
DISPLAY_HELP
);
Optional
<
Boolean
>
flag
=
settings
.
isTrue
(
SettingType
.
INHIBIT_PRINT
);
Assertions
.
assertFalse
(
flag
.
isPresent
());
}
@Test
void
testParameterRecognized
()
{
final
String
param
=
"xyz"
;
String
[]
args
=
{
"--csv-path"
,
param
};
String
[]
args
=
{
"--csv-path"
,
param
,
"-p"
,
param
,
"-t"
,
param
,
"-x"
,
param
,
"-y"
,
param
,
"-d"
,
param
};
SettingsReader
settings
;
try
{
settings
=
commandLineParser
.
parse
(
args
);
...
...
@@ -72,14 +76,21 @@ class CommandLineParserTest {
fail
();
return
;
// Never executed, satisfy compiler
}
Optional
<
String
>
flag
=
settings
.
getSetting
(
SettingType
.
CSV_LOCATION
);
Assertions
.
assertTrue
(
flag
.
isPresent
());
Assertions
.
assertTrue
(
flag
.
get
().
equals
(
param
));
Optional
<
String
>
flag
;
for
(
SettingType
setting
:
new
SettingType
[]{
SettingType
.
CSV_LOCATION
,
SettingType
.
PRINTER_CONFIG_PATH
,
SettingType
.
DIAGRAM_TITLE
,
SettingType
.
X_AXIS_LABEL
,
SettingType
.
X_AXIS_LABEL
,
SettingType
.
DIAGRAM_TYPE
}
)
{
flag
=
settings
.
getSetting
(
setting
);
Assertions
.
assertTrue
(
flag
.
isPresent
());
Assertions
.
assertTrue
(
flag
.
get
().
equals
(
param
));
}
}
@Test
void
testParameterCorrectlyNotRecognized
()
{
String
[]
args
=
{
""
};
final
String
param
=
"xyz"
;
String
[]
args
=
{
"--csv-path"
,
param
,
"-p"
,
param
,
"-t"
,
param
,
"-x"
,
param
,
"-y"
,
param
,
"-d"
,
param
};
SettingsReader
settings
;
try
{
settings
=
commandLineParser
.
parse
(
args
);
...
...
@@ -87,7 +98,7 @@ class CommandLineParserTest {
fail
();
return
;
// Never executed, satisfy compiler
}
Optional
<
String
>
flag
=
settings
.
getSetting
(
SettingType
.
C
SV
_LOCATION
);
Optional
<
String
>
flag
=
settings
.
getSetting
(
SettingType
.
SV
G_EXPORT
);
Assertions
.
assertFalse
(
flag
.
isPresent
());
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment