@Test public void test_checkVaultSealStatus_failure() { Response responseNotFound = getMockResponse(HttpStatus.NOT_FOUND, true, ""); ResponseEntity<String> responseEntityExpected = ResponseEntity.status(HttpStatus.NOT_FOUND).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); when( reqProcessor.process("/seal-status","{}","")).thenReturn(responseNotFound); when(reqProcessor.process("/v2/seal-status","{}","")).thenReturn(responseNotFound); ResponseEntity<String> responseEntity = sysService.checkVaultSealStatus(); assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }
public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } }
SysService { public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } } }
SysService { public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } }  }
SysService { public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } }  ResponseEntity<String> checkVaultHealth(); ResponseEntity<String> checkVaultSealStatus(); ResponseEntity<String> unseal(Unseal unseal); ResponseEntity<String> unsealProgress(String serverip); }
SysService { public ResponseEntity<String> checkVaultSealStatus() { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Trying to get Seal-Status of Vault Server"). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); Response response = reqProcessor.process("/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { response = reqProcessor.process("/v2/seal-status","{}",""); if(HttpStatus.OK.equals(response.getHttpstatus())) { return ResponseEntity.status(HttpStatus.OK).body("{\"messages\":"+response.getResponse()+"}"); } else { log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "Check Seal-status"). put(LogMessage.MESSAGE, "Getting Vault Seal-Status failed."). put(LogMessage.RESPONSE, response.getResponse()). put(LogMessage.STATUS, response.getHttpstatus().toString()). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); return ResponseEntity.status(response.getHttpstatus()).body("{\"Error\":[\"Unable to get Seal-Status information\"]}"); } } }  ResponseEntity<String> checkVaultHealth(); ResponseEntity<String> checkVaultSealStatus(); ResponseEntity<String> unseal(Unseal unseal); ResponseEntity<String> unsealProgress(String serverip);  }