### Question:
NamespaceHandler { public static Optional<Map.Entry<String, String>> getAlias(final Map<String, String> nsContext, final String namespace) { return nsContext.entrySet() .stream() .filter(k -> k.getValue().equals(namespace)) .findFirst(); }  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 testGetAlias() { final Map<String, String> nsContext = new HashMap<>(); final String included1 = NamespaceHandler.INCLUDED_NAMESPACE + "1"; final String included2 = NamespaceHandler.INCLUDED_NAMESPACE + "2"; final String included3 = NamespaceHandler.INCLUDED_NAMESPACE + "3"; final String ns1 = "http: final String ns2 = "http: final String ns3 = "http: nsContext.put(included1, ns1); nsContext.put(included2, ns2); nsContext.put(included3, ns3); final Optional<Map.Entry<String, String>> actual = NamespaceHandler.getAlias(nsContext, ns2); assertTrue(actual.isPresent()); assertEquals(ns2, actual.get().getValue()); assertEquals(included2, actual.get().getKey()); }
@Test public void testGetAliasNonExistent() { final Map<String, String> nsContext = new HashMap<>(); final String included1 = NamespaceHandler.INCLUDED_NAMESPACE + "1"; final String ns1 = "http: nsContext.put(included1, ns1); final Optional<Map.Entry<String, String>> actual = NamespaceHandler.getAlias(nsContext, "some"); assertFalse(actual.isPresent()); }