@Before
 public void setUp() throws Exception {
   listener = spy(new CommandRequestListener());
   when(payload.getMessage(CommandRequest.class)).thenReturn(commandRequest);
   when(peerManager.getPeer(any(String.class))).thenReturn(sourcePeer);
   when(localPeer.bindHost(any(String.class))).thenReturn(host);
   doReturn(peerManager).when(listener).getPeerManager();
   doReturn(localPeer).when(peerManager).getLocalPeer();
 }
Beispiel #2
0
  @Override
  public void removeRequest(final String requestId) throws HostRegistrationException {
    try {
      RequestedHost requestedHost = requestDataService.find(requestId);

      if (requestedHost != null) {
        requestDataService.remove(requestedHost.getId());

        LocalPeer localPeer = serviceLocator.getService(LocalPeer.class);

        localPeer.removeResourceHost(requestedHost.getId());
      }
    } catch (HostNotFoundException e) {
      LOG.warn("Error removing agent registration request: {}", e.getMessage());
    } catch (Exception e) {
      LOG.error("Error removing agent registration request", e);

      throw new HostRegistrationException(e);
    }
  }