@Test public void testInjectSetterInt() throws NoSuchMethodException { Inject inject = mock(Inject.class); when(inject.findImportMethodOnApi(any(Class.class), anyString(), any(Boolean.class))) .thenReturn(APIClass.class.getDeclaredMethod("setTest", int.class)); when(inject.createLoadForTypeIndex(any(Instructions.class), any(Type.class), anyInt())) .thenReturn(mock(Instruction.class)); InjectSetter instance = new InjectSetter(inject); ClassFile targetClass = new ClassFile(); targetClass.setName("test"); Field field = new Field(targetClass, "test", Type.INT); targetClass.addField(field); instance.injectSetter(targetClass, APIClass.class, field, "test", null); Method injectedMethod = targetClass.findMethod("setTest"); assertNotNull(injectedMethod); Code code = injectedMethod.getCode(); Instructions instructions = code.getInstructions(); assertFalse(instructions.getInstructions().stream() .filter(i -> i.getType() == CHECKCAST) .findAny() .isPresent()); }
public InjectSetter(Inject inject) { this.inject = inject; }
InjectSetter { public InjectSetter(Inject inject) { this.inject = inject; } }
InjectSetter { public InjectSetter(Inject inject) { this.inject = inject; } InjectSetter(Inject inject); }
InjectSetter { public InjectSetter(Inject inject) { this.inject = inject; } InjectSetter(Inject inject); void injectSetter(ClassFile targetClass, Class<?> targetApiClass, Field field, String exportedName, Number setter); int getInjectedSetters(); }
InjectSetter { public InjectSetter(Inject inject) { this.inject = inject; } InjectSetter(Inject inject); void injectSetter(ClassFile targetClass, Class<?> targetApiClass, Field field, String exportedName, Number setter); int getInjectedSetters();  }