### Question:
CryptographicServiceMessage implements Loggeable { public static CryptographicServiceMessage parse(String csmString) throws ParsingException { CryptographicServiceMessage csm = new CryptographicServiceMessage(); StringTokenizer st = new StringTokenizer(csmString, "() \t\n\r\f"); if (!st.nextToken().equalsIgnoreCase("CSM")) throw new ParsingException("Invalid CSM, doesn't start with the \"CSM(\" tag: " + csmString); do { String field = st.nextToken(); int separatorIndex = field.indexOf('/'); if (separatorIndex > 0) { String tag = field.substring(0, separatorIndex).toUpperCase(); String content = ""; if (separatorIndex < field.length()) content = field.substring(separatorIndex + 1); if (tag.equalsIgnoreCase("MCL")) csm.setMCL(content); else csm.addField(tag, content); } else throw new ParsingException("Invalid field, doesn't have a tag: " + field); } while (st.hasMoreTokens()); if (csm.getMCL() == null) throw new ParsingException("Invalid CSM, doesn't contain an MCL: " + csmString); return csm; } CryptographicServiceMessage();  CryptographicServiceMessage(String mcl); void setMCL(String mcl); String getMCL(); void addField(String tag, String content); String getFieldContent(String tag); @Override String toString(); @Override void dump(PrintStream p, String indent); static CryptographicServiceMessage parse(String csmString); static final String MCL_RSI; static final String MCL_KSM; static final String MCL_RSM; static final String MCL_ESM; static final String TAG_RCV; static final String TAG_ORG; static final String TAG_SVR; static final String TAG_KD; static final String TAG_CTP; static final String TAG_CTR; static final String TAG_ERF; }### Answer:
@Test void testParse() throws Throwable { CryptographicServiceMessage result = CryptographicServiceMessage.parse("CSM(MCL/"); assertEquals("", result.getMCL()); }
@Test void testParseThrowsNoSuchElementException() { thrown = assertThrows(NoSuchElementException.class, () -> CryptographicServiceMessage.parse("") ); assertNull(thrown.getMessage()); }
@Test void testParseThrowsNoSuchElementException1() { thrown = assertThrows(NoSuchElementException.class, () -> CryptographicServiceMessage.parse("CSM") ); assertNull(thrown.getMessage()); }
@Test void testParseThrowsNullPointerException() { thrown = assertThrows(NullPointerException.class, () -> CryptographicServiceMessage.parse(null) ); if (isJavaVersionAtMost(JAVA_14)) { assertNull(thrown.getMessage()); } else { assertEquals("Cannot invoke \"String.length()\" because \"str\" is null", thrown.getMessage()); } }
@Test void testParseThrowsParsingException() { thrown = assertThrows(ParsingException.class, () -> CryptographicServiceMessage.parse("CSM(MCL") ); assertEquals("Invalid field, doesn't have a tag: MCL", thrown.getMessage()); }
@Test void testParseThrowsParsingException1() { thrown = assertThrows(ParsingException.class, () -> CryptographicServiceMessage.parse("testCsmString") ); assertEquals("Invalid CSM, doesn't start with the \"CSM(\" tag: testCsmString" , thrown.getMessage() ); }