@Test public void serialize() throws Exception { URLNormalizer<ExtendedURL> normalizer = this.mocker.getInstance( new DefaultParameterizedType(null, URLNormalizer.class, ExtendedURL.class), "contextpath"); Map<String, List<String>> parameters = new HashMap<>(); parameters.put("key1", Arrays.asList("value1")); parameters.put("key2", Arrays.asList("value2", "value3")); ExtendedURL partialURL = new ExtendedURL(Arrays.asList("webjars", "namespace", "one", "two"), parameters); ExtendedURL expectedURL = new ExtendedURL( Arrays.asList("xwiki", "webjars", "namespace", "one", "two"), parameters); when(normalizer.normalize(partialURL)).thenReturn(expectedURL); WebJarsResourceReference reference = new WebJarsResourceReference("namespace", Arrays.asList("one", "two")); reference.addParameter("key1", "value1"); reference.addParameter("key2", new String[]{ "value2", "value3" }); assertEquals(expectedURL, this.mocker.getComponentUnderTest().serialize(reference)); }
@Override public ExtendedURL serialize(WebJarsResourceReference resourceReference) { List<String> segments = new ArrayList<>(); segments.add("webjars"); segments.add(resourceReference.getNamespace()); segments.addAll(resourceReference.getResourceSegments()); ExtendedURL extendedURL = new ExtendedURL(segments, resourceReference.getParameters()); return this.extendedURLNormalizer.normalize(extendedURL); }
WebjarsResourceReferenceSerializer implements ResourceReferenceSerializer<WebJarsResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(WebJarsResourceReference resourceReference) { List<String> segments = new ArrayList<>(); segments.add("webjars"); segments.add(resourceReference.getNamespace()); segments.addAll(resourceReference.getResourceSegments()); ExtendedURL extendedURL = new ExtendedURL(segments, resourceReference.getParameters()); return this.extendedURLNormalizer.normalize(extendedURL); } }
WebjarsResourceReferenceSerializer implements ResourceReferenceSerializer<WebJarsResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(WebJarsResourceReference resourceReference) { List<String> segments = new ArrayList<>(); segments.add("webjars"); segments.add(resourceReference.getNamespace()); segments.addAll(resourceReference.getResourceSegments()); ExtendedURL extendedURL = new ExtendedURL(segments, resourceReference.getParameters()); return this.extendedURLNormalizer.normalize(extendedURL); }  }
WebjarsResourceReferenceSerializer implements ResourceReferenceSerializer<WebJarsResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(WebJarsResourceReference resourceReference) { List<String> segments = new ArrayList<>(); segments.add("webjars"); segments.add(resourceReference.getNamespace()); segments.addAll(resourceReference.getResourceSegments()); ExtendedURL extendedURL = new ExtendedURL(segments, resourceReference.getParameters()); return this.extendedURLNormalizer.normalize(extendedURL); }  @Override ExtendedURL serialize(WebJarsResourceReference resourceReference); }
WebjarsResourceReferenceSerializer implements ResourceReferenceSerializer<WebJarsResourceReference, ExtendedURL> { @Override public ExtendedURL serialize(WebJarsResourceReference resourceReference) { List<String> segments = new ArrayList<>(); segments.add("webjars"); segments.add(resourceReference.getNamespace()); segments.addAll(resourceReference.getResourceSegments()); ExtendedURL extendedURL = new ExtendedURL(segments, resourceReference.getParameters()); return this.extendedURLNormalizer.normalize(extendedURL); }  @Override ExtendedURL serialize(WebJarsResourceReference resourceReference);  }