@Test public void static_factory_with_path_and_methods_collection_sets_values_as_expected() { // given String path = "/" + UUID.randomUUID().toString(); Collection<String> paths = new ArrayList<String>() {{ add(path); }}; Collection<HttpMethod> methodCollection = Arrays.asList(HttpMethod.GET, HttpMethod.PUT); // when MultiMatcher matcher = MultiMatcher.match(paths, methodCollection); // then assertThat(matcher.matchingPathTemplates(), is(paths)); assertThat(matcher.matchingMethods(), is(methodCollection)); assertThat(matcher.isMatchAllMethods(), is(false)); }
@Test public void static_factory_with_path_arg_only_sets_values_as_expected() { // given String path = "/" + UUID.randomUUID().toString(); Collection<String> paths = new ArrayList<String>() {{ add(path); }}; // when MultiMatcher matcher = MultiMatcher.match(paths); // then assertThat(matcher.matchingPathTemplates(), is(paths)); assertThat(matcher.matchingMethods(), notNullValue()); assertThat(matcher.matchingMethods().isEmpty(), is(true)); assertThat(matcher.isMatchAllMethods(), is(true)); }
@SuppressWarnings("ConstantConditions") @Test public void constructor_sets_fields_as_expected() { // given String path1 = "/" + UUID.randomUUID().toString(); String path2 = "/" + UUID.randomUUID().toString(); Collection<String> paths = new ArrayList<String>() {{ add(path1); add(path2); }}; Collection<HttpMethod> methods = Arrays.asList(HttpMethod.CONNECT, HttpMethod.PATCH); boolean matchAllMethods = false; // when MultiMatcher matcher = new MultiMatcher(paths, methods, matchAllMethods); // then assertThat(matcher.matchingPathTemplates(), is(paths)); assertThat(matcher.matchingMethods(), is(methods)); assertThat(matcher.isMatchAllMethods(), is(matchAllMethods)); }
@Test public void static_factory_with_path_and_methods_varargs_sets_values_as_expected() { // given String path = "/" + UUID.randomUUID().toString(); Collection<String> paths = new ArrayList<String>() {{ add(path); }}; HttpMethod[] methodVarargs = new HttpMethod[]{HttpMethod.GET, HttpMethod.PUT}; // when MultiMatcher matcher = MultiMatcher.match(paths, methodVarargs); // then assertThat(matcher.matchingPathTemplates(), is(paths)); assertThat(matcher.matchingMethods(), notNullValue()); assertThat(matcher.matchingMethods().size(), is(methodVarargs.length)); for (HttpMethod expectedMethod : methodVarargs) { assertThat(matcher.matchingMethods().contains(expectedMethod), is(true)); } assertThat(matcher.isMatchAllMethods(), is(false)); }