Skip to content

Commit

Permalink
#136 - remove useless warning
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankHossfeld committed Sep 8, 2020
1 parent cc4c101 commit e1d86ee
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ String generate(String route,

// in case there are more parameters then placesholders, we add them add the end!
long numberOfPlaceHolders = Stream.of(partsOfRoute)
.filter("*"::equals)
.filter(s -> "*".equals(s) || s.startsWith(":"))
.count();
if (params.length > numberOfPlaceHolders) {
String sbExeption = "Warning: route >>" + route + "<< has less parameter placeholder >>" + numberOfPlaceHolders + "<< than the number of parameters in the list of parameters >>" + params.length + "<< --> adding Prameters add the end of the url";
String sbExeption = "Warning: route >>" + route + "<< has less parameter placeholder >>" + numberOfPlaceHolders + "<< than the number of parameters in the list of parameters >>" + params.length + "<< --> adding Parameters add the end of the url";
this.eventBus.fireEvent(LogEvent.create()
.sdmOnly(true)
.addMessage(sbExeption));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,27 @@ void parse34() {
}
}

@Test
void parse35() {
String route = "/application/person/:ptNr/detail/";
try {
RouteResult routeResult = RouteParser.get()
.parse(route,
this.shellConfiguration,
this.routerConfiguration);
Assert.assertThat(routeResult.getShell(),
is("/application"));
Assert.assertThat(routeResult.getRoute(),
is("/application/person/*/detail"));
Assert.assertThat(routeResult.getParameterValues()
.get(0),
is(":ptNr"));
} catch (RouterException e) {
throw new AssertionError("no exception expected here!",
e);
}
}

@Test
void generate01() {
String hash = RouteParser.get()
Expand All @@ -552,4 +573,23 @@ void generate02() {
is("application/person/1/detail"));
}

@Test
void generate03() {
String hash = RouteParser.get()
.generate("/application/person/list",
"A",
"B");
Assert.assertThat(hash,
is("application/person/list/A/B"));
}

@Test
void generate04() {
String hash = RouteParser.get()
.generate("/application/person/list",
"A");
Assert.assertThat(hash,
is("application/person/list/A"));
}

}

0 comments on commit e1d86ee

Please sign in to comment.