source: class SNMPImplTest {
  
      private static final String SYS_OID_REQUEST;
      private static final String SYS_OID_RESPONSE;
      private static final String LOCATION_OID;
      private static final String GET_IP_ADDRESS;
      private static final String SET_IP_ADDRESS;
      private static final Integer SNMP_LISTEN_PORT;
      private static final String COMMUNITY;
      private static final String CISCO_COMMUNITY;
      private static final String VALUE;
      private static final int RETRIES;
      private static final int TIMEOUT;
      private static final int MAXREPETITIONS;
      private static final String SYS_RESPONSE_NAME;
      private static final String SYS_RESPONSE_IMAGE_NAME;
      private static final String SYS_RESPONSE_VENDOR;
      private static final String SYS_RESPONSE_SERIAL_NUMBER;
      private static final String SYS_RESPONSE_PLATFORM_ID;
      private Snmp mockSnmp;
      private SNMPImpl snmpImpl;
  
      @Test
      public void testGetInterfaces() throws Exception {
  
target:         final String baseIfOIB = "1.3.6.1.2.1.2.2.1.";
          final OID ifIndexOID = new OID(baseIfOIB + "1");
          final OID ifAdminStatusOID = new OID(baseIfOIB + "7");
          final OID ifDescrOID = new OID(baseIfOIB + "2");
          final OID ifInErrorsOID = new OID(baseIfOIB + "14");
  
  
          // Generate the test list of interfaces
          final List<IfEntry> testInterfaceEntries = new ArrayList<>();
  
          for (int i = 0; i < 10; i++) {
              IfEntryBuilder ifEntryBuilder = new IfEntryBuilder()
                      .setIfIndex(new InterfaceIndex(i + 1))
                      .setIfAdminStatus(IfEntry.IfAdminStatus.forValue(i % 3))
                      .setIfDescr(new DisplayString(String.format("Interface %s", i)))
                      .setIfInErrors(new Counter32(99L - i));
              testInterfaceEntries.add(ifEntryBuilder.build());
          }
  
          // Set up the response for the mock snmp4j
          // This is responsible for calling the onResponse() callback for SNMP messages
          doAnswer(invocation -> {
              PDU requestPDU = (PDU) invocation.getArguments()[0];
              final ResponseListener callback = (ResponseListener) invocation.getArguments()[3];
  
              // Create the response PDU based on the request PDU
              PDU responsePDU = new PDU();
              responsePDU.setType(PDU.GET);
  
              // Get the OID of the request
              assertEquals("Checking size of PDU response variable bindings", 1, requestPDU.getVariableBindings().size());
              OID requestOID = requestPDU.getVariableBindings().get(0).getOid();
  
              for (int i = 0; i < testInterfaceEntries.size(); i++) {
                  IfEntry testIfEntry = testInterfaceEntries.get(i);
                  int[] prefix = requestOID.getValue();
                  Variable val = null;
  
                  if (requestOID.equals(ifIndexOID)) {
                      // Add all of the ifIndexes to the response
                      val = new Integer32(i + 1);
  
                  } else if (requestOID.equals(ifAdminStatusOID)) {
                      val = new Integer32(i % 3);
  
                  } else if (requestOID.equals(ifDescrOID)) {
                      val = new OctetString(testIfEntry.getIfDescr().toString());
  
                  } else if (requestOID.equals(ifInErrorsOID)) {
                      val = new org.snmp4j.smi.Counter32(testIfEntry.getIfInErrors().getValue());
  
                  } else {
                      // Don't add any variable bindings to the response
                      break;
                  }
  
                  if (val != null) {
                      OID objOID = new OID(prefix, i);
                      responsePDU.add(new VariableBinding(objOID, val));
                  }
              }
  
              ResponseEvent responseEvent = new ResponseEvent(mockSnmp,
                      new UdpAddress(Inet4Address.getByName(GET_IP_ADDRESS), SNMP_LISTEN_PORT),
                      requestPDU,
                      responsePDU,
                      null,
                      null);
  
              callback.onResponse(responseEvent);
              return null;
          }).when(mockSnmp).send(any(PDU.class), any(Target.class), any(), (ResponseListener) any());
  
          Ipv4Address ip = new Ipv4Address(GET_IP_ADDRESS);
          GetInterfacesInputBuilder input = new GetInterfacesInputBuilder();
          input.setCommunity(COMMUNITY);
          input.setIpAddress(ip);
  
          RpcResult<GetInterfacesOutput> result = null;
          Future<RpcResult<GetInterfacesOutput>> resultFuture = snmpImpl.getInterfaces(input.build());
          result = resultFuture.get();
          assertTrue(result.isSuccessful());
      }
  
  }