### Question:
NamespaceHandler { public static String addIncludedNamespace(final Map<String, String> nsContext, final String namespace) { final Optional<Map.Entry<String, String>> existingNamespace = getAlias(nsContext, namespace); if (existingNamespace.isPresent()) { return existingNamespace.get().getKey(); } final String alias = getFreeIncludedNamespaceId(nsContext); nsContext.put(alias, namespace); return alias; }  static String addIncludedNamespace(final Map<String, String> nsContext,
                                              final String namespace); static Optional<Map.Entry<String, String>> getAlias(final Map<String, String> nsContext,
                                                               final String namespace);  }### Answer:
@Test public void testAddIncludedNamespace() { final Map<String, String> nsContext = new HashMap<>(); final String namespace = "some_namespace"; final String expectedAlias = NamespaceHandler.INCLUDED_NAMESPACE + "1"; final String actual = NamespaceHandler.addIncludedNamespace(nsContext, namespace); assertEquals(1, nsContext.size()); assertEquals(expectedAlias, actual); assertEquals(namespace, nsContext.get(expectedAlias)); }
@Test public void testAddExistingIncludedNamespace() { final Map<String, String> nsContext = new HashMap<>(); final String namespace = "some_namespace"; final String expectedAlias = NamespaceHandler.INCLUDED_NAMESPACE + "1"; nsContext.put(expectedAlias, namespace); final String actual = NamespaceHandler.addIncludedNamespace(nsContext, namespace); assertEquals(1, nsContext.size()); assertEquals(expectedAlias, actual); assertEquals(namespace, nsContext.get(expectedAlias)); }