### Question:
RangeEnforcer { public String enrichQueryString(String queryString) { int maxRange = getMaxRange(); return enforceRange(enforceRange(queryString , maxRange, fromRangePattern, "from", false), maxRange, toRangePattern, "to"); }  String enrichQueryString(String queryString);  }### Answer:
@Test public void testAddRange() { String queryString = "?"; String result = enforcer.enrichQueryString(queryString); assertThat(result).isEqualTo("?to=100"); }
@Test public void testReplaceRange() { String queryString = "?from=50&to=150"; String result = enforcer.enrichQueryString(queryString); assertThat(result).isEqualTo("?from=50&to=100"); }
@Test public void testReplaceRange2() { String queryString = "?from=150&to=250"; String result = enforcer.enrichQueryString(queryString); assertThat(result).isEqualTo("?from=100&to=100"); }
@Test public void testReplaceRange3() { String queryString = "?from=150&to=50"; String result = enforcer.enrichQueryString(queryString); assertThat(result).isEqualTo("?from=100&to=50"); }
@Test public void testReplaceRange4() { String queryString = "?from=150"; String result = enforcer.enrichQueryString(queryString); assertThat(result).isEqualTo("?from=100&to=100"); }
@Test public void testRangeNoChange() { String queryString = "?from=1&to=50"; String result = enforcer.enrichQueryString(queryString); assertThat(result).isEqualTo("?from=1&to=50"); }
@Test public void testRangeNoInfo() { context = new SecurityContextImpl(); User principal = new User("USER1", "USER1", new ArrayList<GrantedAuthority>()); Authentication authentication = new TestingAuthenticationToken(principal , null); context.setAuthentication(authentication); SecurityContextHolder.setContext(context); String queryString = "?from=101&to=150"; String result = enforcer.enrichQueryString(queryString); assertThat(result).isEqualTo("?from=101&to=150"); }