View Javadoc
1   package de.japrost.jabudget.spring;
2   
3   import java.lang.reflect.Field;
4   import java.util.HashSet;
5   import java.util.Set;
6   
7   import org.assertj.core.api.Assertions;
8   import org.junit.Test;
9   
10  /**
11   * Test the {@link PathMapping}.
12   */
13  public class PathMappingTest implements PathMapping {
14  
15  	/**
16  	 * Test that no duplicates exists in path definition
17  	 *
18  	 * @throws Exception never
19  	 */
20  	@Test
21  	public void noDuplicateNames() throws Exception {
22  		final Field[] declaredFields = PathMapping.class.getDeclaredFields();
23  		final Set<String> path = new HashSet<>();
24  		for (final Field field : declaredFields) {
25  			if (field.getType().isAssignableFrom(String.class)) {
26  				Assertions.assertThat(path.add((String) field.get(null))).isTrue();
27  			}
28  		}
29  	}
30  
31  	// TODO how / where to put integration tests?
32  }