### Question:
CheckSignatureAdapter extends SignatureVisitor { @Override public void visitClassType(final String name) { if (type != TYPE_SIGNATURE || state != State.EMPTY) { throw new IllegalStateException(); } checkClassName(name, "class name"); state = State.CLASS_TYPE; if (signatureVisitor != null) { signatureVisitor.visitClassType(name); } } CheckSignatureAdapter(final int type, final SignatureVisitor signatureVisitor); protected  CheckSignatureAdapter(
      final int api, final int type, final SignatureVisitor signatureVisitor); @Override void visitFormalTypeParameter(final String name); @Override SignatureVisitor visitClassBound(); @Override SignatureVisitor visitInterfaceBound(); @Override SignatureVisitor visitSuperclass(); @Override SignatureVisitor visitInterface(); @Override SignatureVisitor visitParameterType(); @Override SignatureVisitor visitReturnType(); @Override SignatureVisitor visitExceptionType(); @Override void visitBaseType(final char descriptor); @Override void visitTypeVariable(final String name); @Override SignatureVisitor visitArrayType(); @Override void visitClassType(final String name); @Override void visitInnerClassType(final String name); @Override void visitTypeArgument(); @Override SignatureVisitor visitTypeArgument(final char wildcard); @Override void visitEnd(); static final int CLASS_SIGNATURE; static final int METHOD_SIGNATURE; static final int TYPE_SIGNATURE; }### Answer:
@Test public void testVisitClassType_classSignature_illegalState() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.CLASS_SIGNATURE, null); Executable visitClassType = () -> checkSignatureAdapter.visitClassType("A"); assertThrows(IllegalStateException.class, visitClassType); }
@Test public void testVisitClassType_typeSignature_nullArgument() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE, null); Executable visitClassType = () -> checkSignatureAdapter.visitClassType(null); Exception exception = assertThrows(IllegalArgumentException.class, visitClassType); assertEquals("Invalid class name (must not be null or empty)", exception.getMessage()); }
@Test public void testVisitClassType_typeSignature_emptyArgument() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE, null); Executable visitClassType = () -> checkSignatureAdapter.visitClassType(""); Exception exception = assertThrows(IllegalArgumentException.class, visitClassType); assertEquals("Invalid class name (must not be null or empty)", exception.getMessage()); }
@Test public void testVisitClassType_typeSignature_illegalArgument() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE, null); Executable visitClassType = () -> checkSignatureAdapter.visitClassType("<A>"); Exception exception = assertThrows(IllegalArgumentException.class, visitClassType); assertEquals( "Invalid class name (must not contain . ; [ < > or :): <A>", exception.getMessage()); }
@Test public void testVisitClassType_typeSignature_illegalState() { CheckSignatureAdapter checkSignatureAdapter = new CheckSignatureAdapter(CheckSignatureAdapter.TYPE_SIGNATURE, null); checkSignatureAdapter.visitClassType("A"); Executable visitClassType = () -> checkSignatureAdapter.visitClassType("A"); assertThrows(IllegalStateException.class, visitClassType); }