List of usage examples for org.springframework.restdocs.constraints Constraint Constraint
public Constraint(String name, Map<String, Object> configuration)
From source file:capital.scalable.restdocs.constraints.ConstraintAndGroupDescriptionResolverTest.java
@Test public void multipleGroupDescriptionsAreResolved() { // given// ww w . j av a2s. c o m Map<String, Object> configuration = new HashMap<>(); configuration.put(GROUPS, new Class<?>[] { Update.class, Create.class }); Constraint constraint = new Constraint("Constraint", configuration); when(delegate.resolveDescription(eq(constraint))).thenReturn("Must be it"); when(delegate.resolveDescription(not(eq(constraint)))).thenReturn("Must be it (create)", "Must be it (update)"); // when String description = resolver.resolveDescription(constraint); // then assertThat(description, is("Must be it (create), Must be it (update)")); }
From source file:capital.scalable.restdocs.constraints.ConstraintAndGroupDescriptionResolverTest.java
@Test public void groupDescriptionIsNotResolved() { // given//from w ww .j a v a 2 s .c om Map<String, Object> configuration = new HashMap<>(); configuration.put(GROUPS, new Class<?>[] { Update.class }); Constraint constraint = new Constraint("Constraint", configuration); when(delegate.resolveDescription(eq(constraint))).thenReturn("Must be it"); when(delegate.resolveDescription(not(eq(constraint)))).thenThrow(MissingResourceException.class); // when String description = resolver.resolveDescription(constraint); // then assertThat(description, is("Must be it (groups: [Update])")); }
From source file:capital.scalable.restdocs.constraints.ConstraintAndGroupDescriptionResolverTest.java
@Test public void strangeGroupConfigurationIsResolved() { // given// www .ja va 2 s . co m Map<String, Object> configuration = new HashMap<>(); configuration.put(GROUPS, "no group"); Constraint constraint = new Constraint("Constraint", configuration); when(delegate.resolveDescription(eq(constraint))).thenReturn("Must be it"); when(delegate.resolveDescription(not(eq(constraint)))).thenReturn("here"); // when String description = resolver.resolveDescription(constraint); // then assertThat(description, is("Must be it")); }
From source file:capital.scalable.restdocs.constraints.ConstraintAndGroupDescriptionResolverTest.java
@Test public void noConstraintDescriptionIsResolved() { // given/*from w w w . j av a2 s. co m*/ Map<String, Object> configuration = new HashMap<>(); configuration.put(GROUPS, new Class<?>[] { Update.class }); Constraint constraint = new Constraint("Constraint", configuration); when(delegate.resolveDescription(eq(constraint))).thenReturn(""); // when String description = resolver.resolveDescription(constraint); // then assertThat(description, is("Constraint (groups: [Update])")); }
From source file:capital.scalable.restdocs.constraints.ConstraintAndGroupDescriptionResolverTest.java
@Test public void noGroupsResolved() { // given/*from w ww .ja va 2 s. c om*/ Constraint constraint = new Constraint("Constraint", Collections.<String, Object>emptyMap()); // when List<Class> groups = resolver.getGroups(constraint); // then assertThat(groups.size(), is(0)); }
From source file:capital.scalable.restdocs.constraints.ConstraintAndGroupDescriptionResolverTest.java
@Test public void groupsResolved() { // given//from w w w. j av a2s. c o m Map<String, Object> configuration = new HashMap<>(); configuration.put(GROUPS, new Class<?>[] { Update.class, Create.class }); Constraint constraint = new Constraint("Constraint", configuration); // when List<Class> groups = resolver.getGroups(constraint); // then assertThat(groups.size(), is(2)); assertThat(groups.get(0), equalTo((Class) Update.class)); assertThat(groups.get(1), equalTo((Class) Create.class)); }