Add unit test for functional RM JMX data

This commit is contained in:
BoykoAlex
2018-09-07 16:16:47 -04:00
parent 68f54e42b5
commit 276eb4d84e

View File

@@ -12,7 +12,9 @@ package org.springframework.ide.vscode.commons.boot.app.cli;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
@@ -20,6 +22,8 @@ import org.junit.Test;
import org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMapping;
import org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMappingsParser20;
import com.google.common.collect.ImmutableSet;
public class Boot2xRequestMappingsTest {
@Test
@@ -27,13 +31,62 @@ public class Boot2xRequestMappingsTest {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-web.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(10, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/error",
"/actuator",
"/actuator/health",
"/actuator/info",
"/hello",
"/qq",
"/pp"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
@Test
public void testWebFluxAnnotationRms() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(7, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/actuator",
"/actuator/health",
"/actuator/info",
"/hello",
"/pp",
"/qq"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
@Test
public void testWebFluxAnnotationRmsFunctional() throws Exception {
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux-functional.json"));
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
assertEquals(6, rms.size());
ImmutableSet<String> expected = ImmutableSet.of(
"/actuator",
"/actuator/health",
"/actuator/info"
);
assertEquals(expected,
rms.stream()
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
.collect(Collectors.toSet())
);
}
}