### Question:
TppServiceInternal implements TppService { @Override @Transactional public CmsResponse<Boolean> updateTppInfo(@NotNull TppInfo tppInfo) { Optional<TppInfoEntity> tppInfoEntityOptional = tppInfoRepository.findFirstByAuthorisationNumberAndInstanceId(tppInfo.getAuthorisationNumber(), serviceInstanceId); if (tppInfoEntityOptional.isEmpty()) { return CmsResponse.<Boolean>builder() .payload(false) .build(); } TppInfoEntity tppInfoEntity = tppInfoEntityOptional.get(); if (isRolesChanged(tppInfoEntity.getTppRoles(), tppInfo.getTppRoles())) { tppInfoEntity.setTppRoles(tppInfo.getTppRoles()); } return CmsResponse.<Boolean>builder() .payload(true) .build(); }  @Override @Transactional CmsResponse<Boolean> updateTppInfo(@NotNull TppInfo tppInfo);  }### Answer:
@Test void updateTppInfo_tppNotFound() { when(tppInfoRepository.findFirstByAuthorisationNumberAndInstanceId(tppInfo.getAuthorisationNumber(), INSTANCE_ID)).thenReturn(Optional.empty()); CmsResponse<Boolean> updateTppInfo = tppServiceInternal.updateTppInfo(tppInfo); assertTrue(updateTppInfo.isSuccessful()); assertFalse(updateTppInfo.getPayload()); verify(tppInfoRepository, never()).save(any(TppInfoEntity.class)); }
@Test void updateTppInfo_tppFoundAndUpdated() { tppInfoEntity.setTppRoles(null); ArgumentCaptor<TppInfoEntity> argument = ArgumentCaptor.forClass(TppInfoEntity.class); when(tppInfoRepository.findFirstByAuthorisationNumberAndInstanceId(tppInfo.getAuthorisationNumber(), INSTANCE_ID)).thenReturn(Optional.of(tppInfoEntity)); CmsResponse<Boolean> updateTppInfo = tppServiceInternal.updateTppInfo(tppInfo); assertTrue(updateTppInfo.isSuccessful()); assertTrue(updateTppInfo.getPayload()); }
@Test void updateTppInfo_tppFoundAndRolesNotChangedAndUpdated() { when(tppInfoRepository.findFirstByAuthorisationNumberAndInstanceId(tppInfo.getAuthorisationNumber(), INSTANCE_ID)).thenReturn(Optional.of(tppInfoEntity)); CmsResponse<Boolean> updateTppInfo = tppServiceInternal.updateTppInfo(tppInfo); assertTrue(updateTppInfo.isSuccessful()); assertTrue(updateTppInfo.getPayload()); verify(tppInfoRepository, never()).save(any(TppInfoEntity.class)); }