ParamProcessors { public static ParamProcessor newInstance(ParamType type, String listSeparator){ switch(type){ case COOKIE: return listSeparator != null ? new CollectionMergingCookieParamProcessor(listSeparator) : DefaultCookieParamProcessor.INSTANCE; default: return listSeparator != null ? new CollectionMergingParamProcessor(listSeparator) : DefaultParamProcessor.INSTANCE; } } private  ParamProcessors(); static ParamProcessor newInstance(ParamType type, String listSeparator); static Iterator<EncodedPair> iterate(List<Param> params, Charset charset); static Iterator<EncodedPair> iterate(List<Param> params, Charset charset, boolean encodeIfNeeded);  }
@Test public void shouldReturnAnInstanceOfCollectionMergingCookieProcessor() throws Exception { CollectionMergingCookieParamProcessor expected = mock(CollectionMergingCookieParamProcessor.class); whenNew(CollectionMergingCookieParamProcessor.class).withArguments("-").thenReturn(expected); ParamProcessor actual = ParamProcessors.newInstance(ParamType.COOKIE, "-"); assertSame(expected, actual); }
@Test public void shouldReturnAnInstanceOfDefaultCookieProcessor() throws Exception { ParamProcessor actual = ParamProcessors.newInstance(ParamType.COOKIE, null); assertSame(DefaultCookieParamProcessor.INSTANCE, actual); }
@Test public void shouldReturnAnInstanceOfCollectionMergingDefaultProcessorForQuery() throws Exception { CollectionMergingParamProcessor expected = mock(CollectionMergingParamProcessor.class); whenNew(CollectionMergingParamProcessor.class).withArguments("-").thenReturn(expected); ParamProcessor actual = ParamProcessors.newInstance(ParamType.QUERY, "-"); assertSame(expected, actual); }
@Test public void shouldReturnAnInstanceOfDefaultProcessorForQuery() throws Exception { ParamProcessor actual = ParamProcessors.newInstance(ParamType.QUERY, null); assertSame(DefaultParamProcessor.INSTANCE, actual); }
@Test public void shouldReturnAnInstanceOfCollectionMergingDefaultProcessorForForm() throws Exception { CollectionMergingParamProcessor expected = mock(CollectionMergingParamProcessor.class); whenNew(CollectionMergingParamProcessor.class).withArguments("-").thenReturn(expected); ParamProcessor actual = ParamProcessors.newInstance(ParamType.FORM, "-"); assertSame(expected, actual); }
@Test public void shouldReturnAnInstanceOfDefaultProcessorForForm() throws Exception { ParamProcessor actual = ParamProcessors.newInstance(ParamType.FORM, null); assertSame(DefaultParamProcessor.INSTANCE, actual); }
@Test public void shouldReturnAnInstanceOfCollectionMergingDefaultProcessorForHeader() throws Exception { CollectionMergingParamProcessor expected = mock(CollectionMergingParamProcessor.class); whenNew(CollectionMergingParamProcessor.class).withArguments("-").thenReturn(expected); ParamProcessor actual = ParamProcessors.newInstance(ParamType.HEADER, "-"); assertSame(expected, actual); }
@Test public void shouldReturnAnInstanceOfDefaultProcessorForHeader() throws Exception { ParamProcessor actual = ParamProcessors.newInstance(ParamType.HEADER, null); assertSame(DefaultParamProcessor.INSTANCE, actual); }
@Test public void shouldReturnAnInstanceOfCollectionMergingDefaultProcessorForMatrix() throws Exception { CollectionMergingParamProcessor expected = mock(CollectionMergingParamProcessor.class); whenNew(CollectionMergingParamProcessor.class).withArguments("-").thenReturn(expected); ParamProcessor actual = ParamProcessors.newInstance(ParamType.MATRIX, "-"); assertSame(expected, actual); }
@Test public void shouldReturnAnInstanceOfDefaultProcessorForMatrix() throws Exception { ParamProcessor actual = ParamProcessors.newInstance(ParamType.MATRIX, null); assertSame(DefaultParamProcessor.INSTANCE, actual); }
@Test public void shouldReturnAnInstanceOfCollectionMergingDefaultProcessorForPath() throws Exception { CollectionMergingParamProcessor expected = mock(CollectionMergingParamProcessor.class); whenNew(CollectionMergingParamProcessor.class).withArguments("-").thenReturn(expected); ParamProcessor actual = ParamProcessors.newInstance(ParamType.PATH, "-"); assertSame(expected, actual); }
@Test public void shouldReturnAnInstanceOfDefaultProcessorForPath() throws Exception { ParamProcessor actual = ParamProcessors.newInstance(ParamType.PATH, null); assertSame(DefaultParamProcessor.INSTANCE, actual); }