Router extends ComponentSupport { @VisibleForTesting Context maybeCopyContextAttributes(final Repository repository, final Request request, final Context existingContext) { Context context = new Context(repository, request); copyLocalContextAttributes(existingContext, context); return context; } Router(final List<Route> routes, final DefaultRoute defaultRoute); Response dispatch(final Repository repository, final Request request, @Nullable final Context existingContext); static final String LOCAL_ATTRIBUTE_PREFIX; }
@Test public void testMaybeCopyContextAttributes() throws Exception { Context existingContext = new Context(repository, request); existingContext.getAttributes().set("somekey", "somevalue"); existingContext.getAttributes().set(LOCAL_ATTRIBUTE_PREFIX + "anotherkey", "anothervalue"); Context newContext = underTest.maybeCopyContextAttributes(repository, request, existingContext); assertThat(newContext.getAttributes().get("somekey"), is("somevalue")); assertThat(newContext.getAttributes().get(LOCAL_ATTRIBUTE_PREFIX + "anotherkey"), nullValue()); }