Peux-tu m'améliorer ce test unitaire stp : void…
- User
Peux-tu m'améliorer ce test unitaire stp :
void givenValidData_whenUpdateOperation_thenSuccess() throws Exception { // given Set agents = new HashSet<>(); agents.add(Agent.builder().actorCode("00000053").bic(randomFullBic()).name("SENDER").role(AgentRole.SENDER).build()); agents.add(Agent.builder().actorCode("00000044").bic(randomFullBic()).name("RECEIVER").role(AgentRole.RECEIVER).build());
codeString operationId = "op-123"; InstitutionFundsTransferCreateCommand dto = mock(InstitutionFundsTransferCreateCommand.class); OperationCreateDto operationCreateDto = mock(OperationCreateDto.class); when(dto.operation()).thenReturn(operationCreateDto); when(operationCreateDto.operationCode()).thenReturn("OPCODE"); InstitutionFundsTransfer existingModel = mock(InstitutionFundsTransfer.class); when(existingModel.getOperationCode()).thenReturn("OPCODE"); when(institutionFundsTransferQueryPort.findFundsTransfer(operationId)) .thenReturn(Optional.of(existingModel)); when(operationCodeRepositoryPort.getOperationCode("OPCODE")) .thenReturn(Optional.of(new OperationCode("JLF6", "JLF6"))); when(agentDtoModelMapper.dtoToModelSet(anySet())) .thenReturn(agents); when(countryQueryPort.fetchAll()).thenReturn(Try.of(() -> List.of(new Country("Fr", "FRANCE")))); when(institutionFundsTransferValidator.validateFundsTransfer(any(), anyList())) .thenReturn(io.vavr.control.Either.right(existingModel)); InstitutionFundsTransferCommandService spyService = Mockito.spy(testedService); when(institutionFundsTransferPersistencePort.persistCashFundsTransfer(any(InstitutionFundsTransfer.class))) .thenReturn(Try.success(existingModel)); // when InstitutionFundsTransfer result = spyService.updateOperation(operationId, any()); // then assertThat(result).isEqualTo(existingModel); verify(institutionFundsTransferQueryPort).findFundsTransfer(operationId); verify(operationCodeRepositoryPort).getOperationCode("OPCODE"); verify(agentDtoModelMapper).dtoToModelSet(anySet()); verify(countryQueryPort).fetchAll(); verify(institutionFundsTransferValidator).validateFundsTransfer(any(), anyList()); verify(rightsPort, times(1)).getConnectedUserCode(); verify(institutionFundsTransferResultDtoToModelMapper, times(1)).toLeft(any()); } Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.