### Question:
SimpleNameSpaceMapper implements NameSpaceMapper { @Override public String mapNameSpace(String originNameSpace) { if (originNameSpace == null) throw new IllegalArgumentException("mapName got null parameer"); return mappings.stream() .filter(x -> (originNameSpace.startsWith(x.originNameSpace()) && !x.exact()) || x.originNameSpace().equals(originNameSpace) && x.exact() ) .findFirst() .map(x -> originNameSpace.replaceFirst("^" + x.originNameSpace(), x.targetNameSpace()).replaceFirst("^\\.", "")) .orElse(originNameSpace); } SimpleNameSpaceMapper( List<NameSpaceMapping>  mappings); @Override String mapNameSpace(String originNameSpace);  }### Answer:
@Test void checkNullAssertion() { assertThrows(IllegalArgumentException.class, () -> { SimpleNameSpaceMapper testee = new SimpleNameSpaceMapper(null); testee.mapNameSpace(null); } ); }
@Test void mapNameSpace() { NameSpaceMapping oneNsMapping = NameSpaceMappingBuilder.of("a.b",""); List<NameSpaceMapping> oneMapping = Collections.singletonList(oneNsMapping); SimpleNameSpaceMapper snsm = new SimpleNameSpaceMapper(oneMapping); assertEquals(snsm.mapNameSpace("a.b"),""); assertEquals(snsm.mapNameSpace("a.b.c"),"c"); assertEquals(snsm.mapNameSpace("a.d"),"a.d"); assertEquals(snsm.mapNameSpace(""),""); }
@Test void mapNameSpaceExact() { NameSpaceMapping oneNsMapping = NameSpaceMappingBuilder.of("a.b","").withExact(true); List<NameSpaceMapping> oneMapping = Collections.singletonList(oneNsMapping); SimpleNameSpaceMapper snsm = new SimpleNameSpaceMapper(oneMapping); assertEquals(snsm.mapNameSpace("a.b"),""); assertEquals(snsm.mapNameSpace("a.b.c"),"a.b.c"); assertEquals(snsm.mapNameSpace("a.d"),"a.d"); assertEquals(snsm.mapNameSpace(""),""); }