/*
 * Copyright 2012-2016 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.boot.configurationprocessor.metadata;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Tests for {@link ConfigurationMetadata}.
 *
 * @author Stephane Nicoll
 */
public class ConfigurationMetadataTests {

	@Test
	public void toDashedCaseCamelCase() {
		assertThat(toDashedCase("simpleCamelCase")).isEqualTo("simple-camel-case");
	}

	@Test
	public void toDashedCaseUpperCamelCaseSuffix() {
		assertThat(toDashedCase("myDLQ"), is("my-d-l-q"));
	}

	@Test
	public void toDashedCaseUpperCamelCaseMiddle() {
		assertThat(toDashedCase("someDLQKey"), is("some-d-l-q-key"));
	}

	@Test
	public void toDashedCaseWordsUnderscore() {
		assertThat(toDashedCase("Word_With_underscore"))
				.isEqualTo("word_with_underscore");
	}

	@Test
	public void toDashedCaseWordsSeveralUnderscores() {
		assertThat(toDashedCase("Word___With__underscore"))
				.isEqualTo("word___with__underscore");
	}

	@Test
	public void toDashedCaseLowerCaseUnderscore() {
		assertThat(toDashedCase("lower_underscore")).isEqualTo("lower_underscore");
	}

	@Test
	public void toDashedCaseUpperUnderscore() {
		assertThat(toDashedCase("UPPER_UNDERSCORE")).isEqualTo("upper_underscore");
	}

	@Test
	public void toDashedCaseMultipleUnderscores() {
		assertThat(toDashedCase("super___crazy")).isEqualTo("super___crazy");
	}

	@Test
	public void toDashedCaseUppercase() {
		assertThat(toDashedCase("UPPERCASE")).isEqualTo("uppercase");
	public void toDashedCaseMultipleUnderscores() {
		assertThat(toDashedCase("super___crazy"), is("super---crazy"));
	}

	@Test
	public void toDashedCaseLowercase() {
		assertThat(toDashedCase("lowercase")).isEqualTo("lowercase");
	}

	private String toDashedCase(String name) {
		return ConfigurationMetadata.toDashedCase(name);
	}

}

@@ -1109,20 +1109,27 @@
 %22myDLQ%22)
-, is
+).isEqualTo
 (%22my-d-l
@@ -1132,17 +1132,16 @@
 -d-l-q%22)
-)
 ;%0A%09%7D%0A%0A%09@
@@ -1234,20 +1234,27 @@
 DLQKey%22)
-, is
+).isEqualTo
 (%22some-d
@@ -1263,17 +1263,16 @@
 -q-key%22)
-)
 ;%0A%09%7D%0A%0A%09@
@@ -1392,22 +1392,22 @@
 To(%22word
-_
+-
 with
-_
+-
 undersco
@@ -1554,17 +1554,17 @@
 word
-___
+---
 with
-__
+--
 unde
@@ -1692,25 +1692,25 @@
 ualTo(%22lower
-_
+-
 underscore%22)
@@ -1754,32 +1754,38 @@
 eUpperUnderscore
+Suffix
 () %7B%0A%09%09assertTha
@@ -1804,55 +1804,37 @@
 se(%22
-UPPER_UNDERSCORE%22)).isEqualTo(%22upper_underscore
+my_DLQ%22)).isEqualTo(%22my-d-l-q
 %22);%0A
@@ -1865,32 +1865,29 @@
 toDashedCase
-Multiple
+Upper
 Underscores(
@@ -1876,33 +1876,38 @@
 eUpperUnderscore
-s
+Middle
 () %7B%0A%09%09assertTha
@@ -1923,27 +1923,26 @@
 dCase(%22s
-uper___craz
+ome_DLQ_ke
 y%22)).isE
@@ -1950,27 +1950,28 @@
 ualTo(%22s
-uper___craz
+ome-d-l-q-ke
 y%22);%0A%09%7D%0A
@@ -1982,111 +1982,8 @@
 est%0A
-%09public void toDashedCaseUppercase() %7B%0A%09%09assertThat(toDashedCase(%22UPPERCASE%22)).isEqualTo(%22uppercase%22);%0A
 %09pub
@@ -2073,12 +2073,19 @@
 zy%22)
-, is
+).isEqualTo
 (%22su
@@ -2097,17 +2097,16 @@
 -crazy%22)
-)
 ;%0A%09%7D%0A%0A%09@

Fix test