@Test
public void testSet() throws IOException, InterruptedException, ExecutionException {

    final ResponseEvent event = createResponseEvent();
    // SET response - because SET is async, use mockito doAnswer to
    // call the ResponseListener callback
    doAnswer(invocation -> {
        ResponseListener callback = (ResponseListener) invocation.getArguments()[3];
        callback.onResponse(event);
        return null;
    }).when(mockSnmp).set(argThat(argument -> {
        if (argument instanceof PDU) {
            PDU pdu = (PDU) argument;
            assertEquals("Checking SET PDU type", pdu.getType(), PDU.SET);
            assertEquals("Checking Value of SET", pdu.getVariableBindings().get(0).toValueString(), VALUE);
            assertEquals("Checking OID of SET", pdu.getVariableBindings().get(0).getOid().toString(),
                    LOCATION_OID);
            return true;
        }
        return false;
    }), argThat(argument -> {
        if (argument instanceof Target) {
            Target target = (Target) argument;
            assertEquals("Checking community of SET", target.getSecurityName().toString(), COMMUNITY);
            assertEquals("Checking target IP", target.getAddress().toString(),
                    SET_IP_ADDRESS + "/" + SNMP_LISTEN_PORT.toString());
            assertEquals("Checking timeout", target.getTimeout(), TIMEOUT);
            assertEquals("Checking retries", target.getRetries(), RETRIES);
            assertEquals("Checking version", target.getVersion(), SnmpConstants.version2c);
            return true;
        }
        return false;
    }), any(), (ResponseListener) any());
    Ipv4Address ip = new Ipv4Address(SET_IP_ADDRESS);
    SnmpSetInputBuilder input = new SnmpSetInputBuilder();
    input.setCommunity(COMMUNITY);
    input.setIpAddress(ip);
    input.setOid(LOCATION_OID);
    input.setValue(VALUE);
    RpcResult<SnmpSetOutput> result  = snmpImpl.snmpSet(input.build()).get();
    assertTrue(result.isSuccessful());
}