-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add HeaderTemplate create tests for fail * - added expand test * - remove redundant public static identifier from Retryer inner class * - remove redundant public static identifier from Default inner class * add license to test * mvn clean install to format test file
- Loading branch information
Showing
3 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright 2012-2019 The Feign Authors | ||
* | ||
* <p>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 | ||
* | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p>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 feign.template; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
public class HeaderTemplateTest { | ||
|
||
@Rule public ExpectedException exception = ExpectedException.none(); | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void it_should_throw_exception_when_name_is_null() { | ||
HeaderTemplate.create(null, Arrays.asList("test")); | ||
exception.expectMessage("name is required."); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void it_should_throw_exception_when_name_is_empty() { | ||
HeaderTemplate.create("", Arrays.asList("test")); | ||
exception.expectMessage("name is required."); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void it_should_throw_exception_when_value_is_null() { | ||
HeaderTemplate.create("test", null); | ||
exception.expectMessage("values are required"); | ||
} | ||
|
||
@Test | ||
public void it_should_return_name() { | ||
HeaderTemplate headerTemplate = | ||
HeaderTemplate.create("test", Arrays.asList("test 1", "test 2")); | ||
assertEquals("test", headerTemplate.getName()); | ||
} | ||
|
||
@Test | ||
public void it_should_return_expanded() { | ||
HeaderTemplate headerTemplate = HeaderTemplate.create("hello", Arrays.asList("emre", "savci")); | ||
assertEquals("hello emre, savci", headerTemplate.expand(Collections.emptyMap())); | ||
assertEquals( | ||
"hello emre, savci", headerTemplate.expand(Collections.singletonMap("name", "firsts"))); | ||
} | ||
} |