@Test public void testCreateCommandWhenInboundCommandNotExist() { final TransporterCommand command = mock(TransporterCommand.class); when(mockCommandOrchestrator.isInboundCommandExist(command.getRefId())).thenReturn(false); final ResponseEntity<?> result = commandControllerUnderTest.createCommand(command); assertEquals(result.getStatusCode(), HttpStatus.ACCEPTED); verify(mockCommandOrchestrator).receive(any(InboundCommand.class)); }
@PostMapping("/commands") public ResponseEntity<?> createCommand(@RequestBody final TransporterCommand command) { if(commandOrchestrator.isInboundCommandExist(command.getRefId())){ return new ResponseEntity<>(HttpStatus.CONFLICT); } this.commandOrchestrator.receive(commandMapper.transform(command)); return new ResponseEntity<>( HttpStatus.ACCEPTED ); }
CommandController { @PostMapping("/commands") public ResponseEntity<?> createCommand(@RequestBody final TransporterCommand command) { if(commandOrchestrator.isInboundCommandExist(command.getRefId())){ return new ResponseEntity<>(HttpStatus.CONFLICT); } this.commandOrchestrator.receive(commandMapper.transform(command)); return new ResponseEntity<>( HttpStatus.ACCEPTED ); } }
CommandController { @PostMapping("/commands") public ResponseEntity<?> createCommand(@RequestBody final TransporterCommand command) { if(commandOrchestrator.isInboundCommandExist(command.getRefId())){ return new ResponseEntity<>(HttpStatus.CONFLICT); } this.commandOrchestrator.receive(commandMapper.transform(command)); return new ResponseEntity<>( HttpStatus.ACCEPTED ); } @Autowired  CommandController(
        final CommandMapper commandMapper,		
        final CommandOrchestrator commandOrchestrator,
        final CommandRepository commandRepository
    ); }
CommandController { @PostMapping("/commands") public ResponseEntity<?> createCommand(@RequestBody final TransporterCommand command) { if(commandOrchestrator.isInboundCommandExist(command.getRefId())){ return new ResponseEntity<>(HttpStatus.CONFLICT); } this.commandOrchestrator.receive(commandMapper.transform(command)); return new ResponseEntity<>( HttpStatus.ACCEPTED ); } @Autowired  CommandController(
        final CommandMapper commandMapper,		
        final CommandOrchestrator commandOrchestrator,
        final CommandRepository commandRepository
    ); @PostMapping("/commands") ResponseEntity<?> createCommand(@RequestBody final TransporterCommand command); @PostMapping("/commands/{commandId}/restart") ResponseEntity<?> restartCommand(@PathVariable("commandId") final String commandId); @PostMapping("/commands/prepare") ResponseEntity<?> prepareCommand(@RequestBody final TransporterCommand command); }
CommandController { @PostMapping("/commands") public ResponseEntity<?> createCommand(@RequestBody final TransporterCommand command) { if(commandOrchestrator.isInboundCommandExist(command.getRefId())){ return new ResponseEntity<>(HttpStatus.CONFLICT); } this.commandOrchestrator.receive(commandMapper.transform(command)); return new ResponseEntity<>( HttpStatus.ACCEPTED ); } @Autowired  CommandController(
        final CommandMapper commandMapper,		
        final CommandOrchestrator commandOrchestrator,
        final CommandRepository commandRepository
    ); @PostMapping("/commands") ResponseEntity<?> createCommand(@RequestBody final TransporterCommand command); @PostMapping("/commands/{commandId}/restart") ResponseEntity<?> restartCommand(@PathVariable("commandId") final String commandId); @PostMapping("/commands/prepare") ResponseEntity<?> prepareCommand(@RequestBody final TransporterCommand command);  }