### Question:
TargetType { public static TypeDescription resolve(TypeDescription typeDescription, TypeDescription targetType) { int arity = 0; TypeDescription componentType = typeDescription; while (componentType.isArray()) { componentType = componentType.getComponentType(); arity++; } return componentType.represents(TargetType.class) ? TypeDescription.ArrayProjection.of(targetType, arity) : typeDescription; } private  TargetType(); static TypeDescription resolve(TypeDescription typeDescription, TypeDescription targetType); static final TypeDescription DESCRIPTION; }### Answer:
@Test public void testIsNotTargetType() throws Exception { when(typeDescription.represents(TargetType.class)).thenReturn(false); assertThat(TargetType.resolve(typeDescription, targetType), is(typeDescription)); }
@Test public void testIsTargetType() throws Exception { when(typeDescription.represents(TargetType.class)).thenReturn(true); assertThat(TargetType.resolve(typeDescription, targetType), is(targetType)); }
@Test public void testIsNotTargetTypeArray() throws Exception { when(typeDescription.isArray()).thenReturn(true); when(typeDescription.getComponentType()).thenReturn(componentType); when(componentType.represents(TargetType.class)).thenReturn(false); assertThat(TargetType.resolve(typeDescription, targetType), is(typeDescription)); }
@Test public void testIsTargetTypeArray() throws Exception { when(typeDescription.isArray()).thenReturn(true); when(typeDescription.getComponentType()).thenReturn(componentType); when(componentType.represents(TargetType.class)).thenReturn(true); TypeDescription resolvedType = TargetType.resolve(typeDescription, targetType); assertThat(resolvedType.isArray(), is(true)); assertThat(resolvedType.getComponentType(), is(targetType)); }