FossologyHandler implements FossologyService.Iface { @Override public RequestStatus checkConnection() throws TException { return fossologySshConnector.runInFossologyViaSsh("exit 2") == 2 ? RequestStatus.SUCCESS : RequestStatus.FAILURE; } @Autowired  FossologyHandler(FossologyFileHandler fossologyFileHandler, FossologyHostKeyHandler fossologyHostKeyHandler, FossologySshConnector fossologySshConnector, FossologyScriptsHandler fossologyScriptsHandler, FossologySettings fossologySettings); @Override RequestStatus sendToFossology(String releaseId, User user, String clearingTeam); @Override RequestStatus sendReleasesToFossology(List<String> releaseIds, User user, String clearingTeam); @Override Release getStatusInFossology(String releaseId, User user, String clearingTeam); @Override List<FossologyHostFingerPrint> getFingerPrints(); @Override RequestStatus setFingerPrints(List<FossologyHostFingerPrint> fingerPrints); @Override RequestStatus deployScripts(); @Override RequestStatus checkConnection(); @Override String getPublicKey();  }
@Test public void testCheckConnection() throws Exception { final RequestStatus requestStatus = RequestStatus.SUCCESS; doReturn(2).when(fossologySshConnector).runInFossologyViaSsh(anyString()); assertThat(fossologyHandler.checkConnection(), is(requestStatus)); verify(fossologySshConnector).runInFossologyViaSsh(anyString()); }
@Test public void testCheckConnectionFailure() throws Exception { final RequestStatus requestStatus = RequestStatus.FAILURE; doReturn(127).when(fossologySshConnector).runInFossologyViaSsh(anyString()); assertThat(fossologyHandler.checkConnection(), is(requestStatus)); verify(fossologySshConnector).runInFossologyViaSsh(anyString()); }