### Question:
CharTagMap extends HashMap<String, CharTag> { public CharTag createTLV(String tagId, String value) throws IllegalArgumentException { validateTag(tagId); int maxValueLength = (int) Math.pow(BigDecimal.TEN.doubleValue(), lenLen) - 1; if (value != null && value.length() > maxValueLength) throw new IllegalArgumentException( String.format("The value size %d of the tag '%s' has" + " exceeded the maximum allowable value %d" , value.length(), tagId, maxValueLength ) ); CharTag tag = new CharTag(tagId, value); tag.setLengthSize(lenLen); tag.withTagLengthSwap(swapTagWithLength); return tag; }  static CharTagMap getInstance(); void unpack(CharSequence data); String pack(); CharTagMap addTag(String tagId, String value); CharTag createTLV(String tagId, String value); String getTagValue(String tagId); boolean hasTag(String tagId);  }### Answer:
@Test public void testCreateTLV() { CharTag tag = instance.createTLV("X7", "test"); assertAll( () -> assertEquals("X7", tag.getTagId()), () -> assertEquals("test", tag.getValue()), () -> assertNull(instance.getTagValue("X7")), () -> assertNull(instance.get("X7")) ); }
@Test public void testCreateTLVWithNullValue() { CharTag tag = instance.createTLV("X7", null); assertAll( () -> assertEquals("X7", tag.getTagId()), () -> assertNull(tag.getValue()), () -> assertNull(instance.get("X7")) ); }
@Test public void testCreateTLVWithTagIdNull() { thrown = assertThrows(IllegalArgumentException.class, () -> instance.createTLV(null, "test") ); assertEquals("Tag identifier have to be specified", thrown.getMessage()); }
@Test public void testCreateTLVWithTagIdInvalidSize() { thrown = assertThrows(IllegalArgumentException.class, () -> instance.createTLV("XYZ", "test") ); assertEquals("Invalid tag 'XYZ' size: expected 2, but got 3", thrown.getMessage()); }
@Test public void testCreateTLVWithValueExceededMaxSize() { thrown = assertThrows(IllegalArgumentException.class, () -> instance.createTLV("XY", ISOUtil.zeropad("", 1000)) ); assertEquals( "The value size 1000 of the tag 'XY' has exceeded the maximum allowable value 999" , thrown.getMessage() ); }