Search in sources :

Example 1 with Boot1xRequestMapping

use of org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping in project sts4 by spring-projects.

the class SpringBootApp method parseRequestMappingsJson.

public static Collection<RequestMapping> parseRequestMappingsJson(String json, String bootVersion) {
    JSONObject obj = new JSONObject(json);
    if (bootVersion.equals("2.x")) {
        return RequestMappingsParser20.parse(obj);
    } else {
        // 1.x
        List<RequestMapping> result = new ArrayList<>();
        Iterator<String> keys = obj.keys();
        while (keys.hasNext()) {
            String rawKey = keys.next();
            JSONObject value = obj.getJSONObject(rawKey);
            result.add(new Boot1xRequestMapping(rawKey, value));
        }
        return result;
    }
}
Also used : Boot1xRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMapping) Boot1xRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping)

Example 2 with Boot1xRequestMapping

use of org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping in project sts4 by spring-projects.

the class Boot1xRequestMappingTest method testSplitPathSimpleCaseWithEmptyOr.

@Test
public void testSplitPathSimpleCaseWithEmptyOr() {
    AbstractRequestMapping rm = new Boot1xRequestMapping("/superpath/mypath || ", null);
    String[] splitPath = rm.getSplitPath();
    assertEquals(1, splitPath.length);
    assertEquals("/superpath/mypath", splitPath[0]);
}
Also used : Boot1xRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping) AbstractRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.AbstractRequestMapping) Test(org.junit.Test)

Example 3 with Boot1xRequestMapping

use of org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping in project sts4 by spring-projects.

the class Boot1xRequestMappingTest method testSplitPathSimpleCase.

@Test
public void testSplitPathSimpleCase() {
    AbstractRequestMapping rm = new Boot1xRequestMapping("{[/superpath/mypath || mypath.json]}", null);
    String[] splitPath = rm.getSplitPath();
    assertEquals(2, splitPath.length);
    assertEquals("/superpath/mypath", splitPath[0]);
    assertEquals("/mypath.json", splitPath[1]);
}
Also used : Boot1xRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping) AbstractRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.AbstractRequestMapping) Test(org.junit.Test)

Example 4 with Boot1xRequestMapping

use of org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping in project sts4 by spring-projects.

the class Boot1xRequestMappingTest method testSplitPathWithoutDuplicate.

@Test
public void testSplitPathWithoutDuplicate() {
    AbstractRequestMapping rm = new Boot1xRequestMapping("/superpath", null);
    String[] splitPath = rm.getSplitPath();
    assertEquals(1, splitPath.length);
    assertEquals("/superpath", splitPath[0]);
}
Also used : Boot1xRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping) AbstractRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.AbstractRequestMapping) Test(org.junit.Test)

Example 5 with Boot1xRequestMapping

use of org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping in project sts4 by spring-projects.

the class Boot1xRequestMappingTest method testSplitPathMultipleCases.

@Test
public void testSplitPathMultipleCases() {
    AbstractRequestMapping rm = new Boot1xRequestMapping("{[/superpath/mypath || mypath.json || somethingelse.what]}", null);
    String[] splitPath = rm.getSplitPath();
    assertEquals(3, splitPath.length);
    assertEquals("/superpath/mypath", splitPath[0]);
    assertEquals("/mypath.json", splitPath[1]);
    assertEquals("/somethingelse.what", splitPath[2]);
}
Also used : Boot1xRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping) AbstractRequestMapping(org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.AbstractRequestMapping) Test(org.junit.Test)

Aggregations

Boot1xRequestMapping (org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.Boot1xRequestMapping)5 Test (org.junit.Test)4 AbstractRequestMapping (org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.AbstractRequestMapping)4 ArrayList (java.util.ArrayList)1 JSONObject (org.json.JSONObject)1 RequestMapping (org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMapping)1