/*
 * Copyright 2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.cloud.stream.metrics;

import org.junit.Assert;
import org.junit.Test;

import org.springframework.boot.bind.RelaxedNames;

/**
 * @author Vinicius Carvalho
 */
public class RelaxedPropertiesUtilsTests {

	@Test
	public void testVariations() throws Exception {
		RelaxedNames javaHome = new RelaxedNames("JAVA_HOME");
		RelaxedNames os = new RelaxedNames("OS");
		RelaxedNames springEnv = new RelaxedNames("SPRING_APPLICATION_NAME");
		RelaxedNames springDot = new RelaxedNames("spring.application.name");
		RelaxedNames springCamel = new RelaxedNames("springApplicationName");
		RelaxedNames contentType = new RelaxedNames("spring.cloud.stream.bindings.streamMetrics.contentType");
		RelaxedNames contentTypeEnv = new RelaxedNames("SPRING_CLOUD_STREAM_BINDINGS_STREAM-METRICS_CONTENT-TYPE");
		RelaxedNames xyz = new RelaxedNames("My.X.Is");
		RelaxedNames springMetrics = new RelaxedNames("spring.cloud.stream.streamMetrics");
		RelaxedNames springMetricsEnv = new RelaxedNames("spring.cloud.stream.stream-metrics");
		Assert.assertEquals("java.home", RelaxedPropertiesUtils.findCanonicalFormat(javaHome));
		Assert.assertEquals("os", RelaxedPropertiesUtils.findCanonicalFormat(os));
		Assert.assertEquals("spring.application.name", RelaxedPropertiesUtils.findCanonicalFormat(springEnv));
		Assert.assertEquals("spring.application.name", RelaxedPropertiesUtils.findCanonicalFormat(springDot));
		Assert.assertEquals("spring.application.name", RelaxedPropertiesUtils.findCanonicalFormat(springCamel));
		Assert.assertEquals("spring.cloud.stream.bindings.streamMetrics.contentType",
				RelaxedPropertiesUtils.findCanonicalFormat(contentType));
		Assert.assertEquals("spring.cloud.stream.bindings.streamMetrics.contentType",
				RelaxedPropertiesUtils.findCanonicalFormat(contentTypeEnv));
		Assert.assertEquals("My.X.Is", RelaxedPropertiesUtils.findCanonicalFormat(xyz));
		Assert.assertEquals("spring.cloud.stream.streamMetrics",
				RelaxedPropertiesUtils.findCanonicalFormat(springMetrics));
		Assert.assertEquals("spring.cloud.stream.streamMetrics",
				RelaxedPropertiesUtils.findCanonicalFormat(springMetricsEnv));
	}

}

@@ -1288,37 +1288,47 @@
 am.bindings.
-streamMetrics
+aggregateMetricsChannel
 .contentType
@@ -1414,22 +1414,33 @@
 NGS_
-STREAM-METRICS
+AGGREGATE-METRICS-CHANNEL
 _CON
@@ -1571,29 +1571,39 @@
 .stream.
-streamMetrics
+aggregateMetricsChannel
 %22);%0A%09%09Re
@@ -1674,22 +1674,33 @@
 eam.
-stream-metrics
+aggregate-metrics-channel
 %22);%0A
@@ -2231,37 +2231,47 @@
 am.bindings.
-streamMetrics
+aggregateMetricsChannel
 .contentType
@@ -2387,29 +2387,39 @@
 indings.
-streamMetrics
+aggregateMetricsChannel
 .content
@@ -2612,37 +2612,47 @@
 loud.stream.
-streamMetrics
+aggregateMetricsChannel
 %22,%0A%09%09%09%09Relax
@@ -2753,21 +2753,31 @@
 eam.
-streamMetrics
+aggregateMetricsChannel
 %22,%0A%09

Apply metrics channel name in RelaxedPropertiesUtilsTests