From 4dfca0cebe122d35b88fe9936df4230c3dbde0a0 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Thu, 26 Oct 2017 21:25:09 -0400 Subject: [PATCH] Fix unit tests --- .../app/cli/requestmappings/RequestMappingImpl1.java | 12 +++++++++++- .../commons/boot/app/cli/RequestMappingImp1Test.java | 10 +++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/headless-services/commons/commons-boot-app-cli/src/main/java/org/springframework/ide/vscode/commons/boot/app/cli/requestmappings/RequestMappingImpl1.java b/headless-services/commons/commons-boot-app-cli/src/main/java/org/springframework/ide/vscode/commons/boot/app/cli/requestmappings/RequestMappingImpl1.java index d3d7b290d..6dd7a2004 100644 --- a/headless-services/commons/commons-boot-app-cli/src/main/java/org/springframework/ide/vscode/commons/boot/app/cli/requestmappings/RequestMappingImpl1.java +++ b/headless-services/commons/commons-boot-app-cli/src/main/java/org/springframework/ide/vscode/commons/boot/app/cli/requestmappings/RequestMappingImpl1.java @@ -159,7 +159,17 @@ There are two styles of entries: @Override public String[] getSplitPath() { String paths = requestPathSupplier.get(); - return Arrays.stream(paths.split("\\|\\|")).map(s -> s.trim()).toArray(String[]::new); + return Arrays.stream(paths.split("\\|\\|")) + .map(s -> s.trim()) + .filter(s -> !s.isEmpty()) + .map(s -> { + if (s.charAt(0) != '/') { + return '/' + s; + } else { + return s; + } + }) + .toArray(String[]::new); } @Override diff --git a/headless-services/commons/commons-boot-app-cli/src/test/java/org/springframework/ide/vscode/commons/boot/app/cli/RequestMappingImp1Test.java b/headless-services/commons/commons-boot-app-cli/src/test/java/org/springframework/ide/vscode/commons/boot/app/cli/RequestMappingImp1Test.java index 803cff043..0e845fd8a 100644 --- a/headless-services/commons/commons-boot-app-cli/src/test/java/org/springframework/ide/vscode/commons/boot/app/cli/RequestMappingImp1Test.java +++ b/headless-services/commons/commons-boot-app-cli/src/test/java/org/springframework/ide/vscode/commons/boot/app/cli/RequestMappingImp1Test.java @@ -38,21 +38,21 @@ public class RequestMappingImp1Test { @Test public void testSplitPathSimpleCase() { - RequestMappingImpl1 rm = new RequestMappingImpl1("/superpath/mypath || mypath.json", null); + RequestMappingImpl1 rm = new RequestMappingImpl1("{[/superpath/mypath || mypath.json]}", null); String[] splitPath = rm.getSplitPath(); assertEquals(2, splitPath.length); assertEquals("/superpath/mypath", splitPath[0]); - assertEquals("/superpath/mypath.json", splitPath[1]); + assertEquals("/mypath.json", splitPath[1]); } @Test public void testSplitPathMultipleCases() { - RequestMappingImpl1 rm = new RequestMappingImpl1("/superpath/mypath || mypath.json || somethingelse.what", null); + RequestMappingImpl1 rm = new RequestMappingImpl1("{[/superpath/mypath || mypath.json || somethingelse.what]}", null); String[] splitPath = rm.getSplitPath(); assertEquals(3, splitPath.length); assertEquals("/superpath/mypath", splitPath[0]); - assertEquals("/superpath/mypath.json", splitPath[1]); - assertEquals("/superpath/somethingelse.what", splitPath[2]); + assertEquals("/mypath.json", splitPath[1]); + assertEquals("/somethingelse.what", splitPath[2]); } }