@Test public void testGetBotStatusWithValidToken() throws Exception { given(botStatusService.getStatus()).willReturn(BOT_STATUS); given(engineConfigService.getEngineConfig()).willReturn(someEngineConfig()); mockMvc .perform( get(STATUS_ENDPOINT_URI) .header( "Authorization", "Bearer " + getJwt(VALID_USER_NAME, VALID_USER_PASSWORD))) .andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.botId").value(BOT_ID)) .andExpect(jsonPath("$.displayName").value(BOT_NAME)) .andExpect(jsonPath("$.status").value(BOT_STATUS)) .andExpect(jsonPath("$.datetime").isNotEmpty()); verify(engineConfigService, times(1)).getEngineConfig(); }
@PreAuthorize("hasRole('USER')") @GetMapping(value = STATUS_RESOURCE_PATH) public BotStatus getStatus(@ApiIgnore Principal principal) { LOG.info( () -> "GET " + STATUS_RESOURCE_PATH + " - getStatus() - caller: " + principal.getName()); final EngineConfig engineConfig = engineConfigService.getEngineConfig(); final String status = botStatusService.getStatus(); final BotStatus botStatus = new BotStatus(); botStatus.setBotId(engineConfig.getBotId()); botStatus.setDisplayName(engineConfig.getBotName()); botStatus.setStatus(status); botStatus.setDatetime(new Date()); LOG.info(() -> "Response: " + botStatus); return botStatus; }
BotStatusController { @PreAuthorize("hasRole('USER')") @GetMapping(value = STATUS_RESOURCE_PATH) public BotStatus getStatus(@ApiIgnore Principal principal) { LOG.info( () -> "GET " + STATUS_RESOURCE_PATH + " - getStatus() - caller: " + principal.getName()); final EngineConfig engineConfig = engineConfigService.getEngineConfig(); final String status = botStatusService.getStatus(); final BotStatus botStatus = new BotStatus(); botStatus.setBotId(engineConfig.getBotId()); botStatus.setDisplayName(engineConfig.getBotName()); botStatus.setStatus(status); botStatus.setDatetime(new Date()); LOG.info(() -> "Response: " + botStatus); return botStatus; } }
BotStatusController { @PreAuthorize("hasRole('USER')") @GetMapping(value = STATUS_RESOURCE_PATH) public BotStatus getStatus(@ApiIgnore Principal principal) { LOG.info( () -> "GET " + STATUS_RESOURCE_PATH + " - getStatus() - caller: " + principal.getName()); final EngineConfig engineConfig = engineConfigService.getEngineConfig(); final String status = botStatusService.getStatus(); final BotStatus botStatus = new BotStatus(); botStatus.setBotId(engineConfig.getBotId()); botStatus.setDisplayName(engineConfig.getBotName()); botStatus.setStatus(status); botStatus.setDatetime(new Date()); LOG.info(() -> "Response: " + botStatus); return botStatus; } @Autowired  BotStatusController(
      BotStatusService botStatusService, EngineConfigService engineConfigService); }
BotStatusController { @PreAuthorize("hasRole('USER')") @GetMapping(value = STATUS_RESOURCE_PATH) public BotStatus getStatus(@ApiIgnore Principal principal) { LOG.info( () -> "GET " + STATUS_RESOURCE_PATH + " - getStatus() - caller: " + principal.getName()); final EngineConfig engineConfig = engineConfigService.getEngineConfig(); final String status = botStatusService.getStatus(); final BotStatus botStatus = new BotStatus(); botStatus.setBotId(engineConfig.getBotId()); botStatus.setDisplayName(engineConfig.getBotName()); botStatus.setStatus(status); botStatus.setDatetime(new Date()); LOG.info(() -> "Response: " + botStatus); return botStatus; } @Autowired  BotStatusController(
      BotStatusService botStatusService, EngineConfigService engineConfigService); @PreAuthorize("hasRole('USER')") @GetMapping(value = STATUS_RESOURCE_PATH) BotStatus getStatus(@ApiIgnore Principal principal); }
BotStatusController { @PreAuthorize("hasRole('USER')") @GetMapping(value = STATUS_RESOURCE_PATH) public BotStatus getStatus(@ApiIgnore Principal principal) { LOG.info( () -> "GET " + STATUS_RESOURCE_PATH + " - getStatus() - caller: " + principal.getName()); final EngineConfig engineConfig = engineConfigService.getEngineConfig(); final String status = botStatusService.getStatus(); final BotStatus botStatus = new BotStatus(); botStatus.setBotId(engineConfig.getBotId()); botStatus.setDisplayName(engineConfig.getBotName()); botStatus.setStatus(status); botStatus.setDatetime(new Date()); LOG.info(() -> "Response: " + botStatus); return botStatus; } @Autowired  BotStatusController(
      BotStatusService botStatusService, EngineConfigService engineConfigService); @PreAuthorize("hasRole('USER')") @GetMapping(value = STATUS_RESOURCE_PATH) BotStatus getStatus(@ApiIgnore Principal principal);  }