### Question:
ByteCodeUtils { public static String signature( TypeReference reference ) { if ( !reference.isGeneric() ) { return null; } return internalSignature( reference ); } private  ByteCodeUtils(); static String byteCodeName( TypeReference reference ); static String outerName( TypeReference reference ); static String typeName( TypeReference reference ); static String desc( MethodDeclaration declaration ); static String desc( MethodReference reference ); static String signature( TypeReference reference ); static String signature( MethodDeclaration declaration ); static String[] exceptions( MethodDeclaration declaration );  }### Answer:
@Test public void signatureShouldBeNullWhenNotGeneric() { TypeReference reference = typeReference( String.class ); String signature = signature( reference ); assertNull( signature ); }
@Test public void signatureShouldBeCorrectWhenGeneric() { TypeReference reference = TypeReference.parameterizedType( List.class, String.class ); String signature = signature( reference ); assertThat( signature, equalTo( "Ljava/util/List<Ljava/lang/String;>;" ) ); }
@Test public void methodSignatureShouldBeNullWhenNotGeneric() { TypeReference owner = typeReference( ByteCodeUtilsTest.class ); MethodDeclaration declaration = method( String.class, "foo", param( String.class, "string" ), param( char[].class, "chararray" ) ) .build( owner ); String signature = signature( declaration ); assertNull( signature ); }
@Test public void methodSignatureShouldBeCorrectWhenGeneric() { TypeReference owner = typeReference( ByteCodeUtilsTest.class ); MethodDeclaration declaration = method( TypeReference.parameterizedType( List.class, String.class ), "foo", param( String.class, "string" ) ) .build( owner ); String signature = signature( declaration ); assertThat( signature, equalTo( "(Ljava/lang/String;)Ljava/util/List<Ljava/lang/String;>;" ) ); }