/*******************************************************************************
 * Copyright (c) 2018 Pivotal, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Pivotal, Inc. - initial API and implementation
 *******************************************************************************/
package org.springframework.ide.vscode.commons.boot.app.cli;

import static org.junit.Assert.assertEquals;

import java.util.Collection;

import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
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;

public class Boot2xRequestMappingsTest {

	@Test
	public void testWebRms() throws Exception {
		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());
	}

	@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());
	}

}

@@ -637,26 +637,87 @@
 va.util.
-Collection
+Arrays;%0Aimport java.util.Collection;%0Aimport java.util.stream.Collectors
 ;%0A%0Aimpor
@@ -992,16 +992,64 @@
 ser20;%0A%0A
+import com.google.common.collect.ImmutableSet;%0A%0A
 public c
@@ -1374,24 +1374,327 @@
 ms.size());%0A
+%0A%09%09ImmutableSet%3CString%3E expected = ImmutableSet.of(%0A%09%09%09%09%22/error%22,%0A%09%09%09%09%22/actuator%22,%0A%09%09%09%09%22/actuator/health%22,%0A%09%09%09%09%22/actuator/info%22,%0A%09%09%09%09%22/hello%22,%0A%09%09%09%09%22/qq%22,%0A%09%09%09%09%22/pp%22%0A%09%09);%0A%09%09assertEquals(expected,%0A%09%09%09%09rms.stream()%0A%09%09%09%09.flatMap(rm -%3E Arrays.stream(rm.getSplitPath()))%0A%09%09%09%09.collect(Collectors.toSet())%0A%09%09);%0A%0A
 %09%7D%0A%0A%09@Test%0A%09
@@ -1959,32 +1959,33 @@
 NObject(json));%0A
+%0A
 %09%09assertEquals(7
@@ -1998,15 +1998,893 @@
 size());
+%0A%0A%09%09ImmutableSet%3CString%3E expected = ImmutableSet.of(%0A%09%09%09%09%22/actuator%22,%0A%09%09%09%09%22/actuator/health%22,%0A%09%09%09%09%22/actuator/info%22,%0A%09%09%09%09%22/hello%22,%0A%09%09%09%09%22/pp%22,%0A%09%09%09%09%22/qq%22%0A%09%09);%0A%09%09assertEquals(expected,%0A%09%09%09%09rms.stream()%0A%09%09%09%09.flatMap(rm -%3E Arrays.stream(rm.getSplitPath()))%0A%09%09%09%09.collect(Collectors.toSet())%0A%09%09);%0A%09%7D%0A%0A%09@Test%0A%09public void testWebFluxAnnotationRmsFunctional() throws Exception %7B%0A%09%09String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream(%22/live-rm-beans/rms-boot2-webflux-functional.json%22));%0A%09%09Collection%3CRequestMapping%3E rms = RequestMappingsParser20.parse(new JSONObject(json));%0A%0A%09%09assertEquals(6, rms.size());%0A%0A%09%09ImmutableSet%3CString%3E expected = ImmutableSet.of(%0A%09%09%09%09%22/actuator%22,%0A%09%09%09%09%22/actuator/health%22,%0A%09%09%09%09%22/actuator/info%22%0A%09%09);%0A%09%09assertEquals(expected,%0A%09%09%09%09rms.stream()%0A%09%09%09%09.flatMap(rm -%3E Arrays.stream(rm.getSplitPath()))%0A%09%09%09%09.collect(Collectors.toSet())%0A%09%09);
 %0A%09%7D%0A
-%0A
 %7D%0A

Add unit test for functional RM JMX data