NavigationContextImpl implements NavigationContext<T> { @Override public Map<String, List<String>> getMutableCopyFilterParameters() { return getMutableCopyFilterParametersInternal(navigationParameters); } NavigationContextImpl(final long shopId,
                                 final long customerShopId,
                                 final String customerLanguage,
                                 final List<Long> categories,
                                 final boolean includeSubCategories,
                                 final Map<String, List<String>> navigationParameters,
                                 final T productQuery,
                                 final T productSkuQuery); @Override long getShopId(); @Override long getCustomerShopId(); @Override String getCustomerLanguage(); @Override List<Long> getCategories(); @Override boolean isIncludeSubCategories(); @Override boolean isGlobal(); @Override boolean isFilteredBy(final String attribute); @Override Set<String> getFilterParametersNames(); @Override List<String> getFilterParameterValues(final String parameterName); @Override Map<String, List<String>> getMutableCopyFilterParameters(); @Override T getProductQuery(); @Override T getProductSkuQuery(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void testGetMutableCopyFilterParameters() throws Exception { final NavigationContextImpl ctx = new NavigationContextImpl(10L, 10L, "en", null, false, new HashMap() {{ put("p1", Arrays.asList("1", "2")); put("p2", Arrays.asList("2", "3")); }}, null, null); assertNotNull(ctx.getFilterParametersNames()); assertFalse(ctx.getFilterParametersNames().isEmpty()); assertTrue(ctx.getFilterParametersNames().contains("p1")); assertTrue(ctx.getFilterParametersNames().contains("p2")); try { ctx.getFilterParametersNames().add("p3"); fail("Must be immutable"); } catch (UnsupportedOperationException uoe) { } try { ctx.getFilterParametersNames().remove("p1"); fail("Must be immutable"); } catch (UnsupportedOperationException uoe) { } assertNotNull(ctx.getFilterParameterValues("p1")); assertFalse(ctx.getFilterParameterValues("p1").isEmpty()); assertEquals("1", ctx.getFilterParameterValues("p1").get(0)); assertEquals("2", ctx.getFilterParameterValues("p1").get(1)); assertEquals("2", ctx.getFilterParameterValues("p2").get(0)); assertEquals("3", ctx.getFilterParameterValues("p2").get(1)); try { ctx.getFilterParameterValues("p1").add("4"); fail("Must be immutable"); } catch (UnsupportedOperationException uoe) { } try { ctx.getFilterParameterValues("p1").remove("1"); fail("Must be immutable"); } catch (UnsupportedOperationException uoe) { } final Map<String, List<String>> copy1 = ctx.getMutableCopyFilterParameters(); assertNotNull(copy1); assertEquals(2, copy1.size()); assertNotNull(copy1.get("p1")); assertEquals("1", copy1.get("p1").get(0)); assertEquals("2", copy1.get("p1").get(1)); assertNotNull(copy1.get("p2")); assertEquals("2", copy1.get("p2").get(0)); assertEquals("3", copy1.get("p2").get(1)); final Map<String, List<String>> copy2 = ctx.getMutableCopyFilterParameters(); assertNotNull(copy2); assertEquals(2, copy2.size()); assertNotNull(copy2.get("p1")); assertEquals("1", copy2.get("p1").get(0)); assertEquals("2", copy2.get("p1").get(1)); assertNotNull(copy2.get("p2")); assertEquals("2", copy2.get("p2").get(0)); assertEquals("3", copy2.get("p2").get(1)); assertNotSame(copy1, copy2); copy1.put("p3", Arrays.asList("3", "4")); copy1.get("p1").add("3"); }