### Question:
CmsAspspTppServiceInternal implements CmsAspspTppService { @Transactional @Override public boolean blockTpp(@NotNull String tppAuthorisationNumber, @NotNull String instanceId, @Nullable Duration lockPeriod) { Optional<TppStopListEntity> stopListEntityOptional = stopListRepository.findByTppAuthorisationNumberAndInstanceId(tppAuthorisationNumber, instanceId); TppStopListEntity entityToBeBlocked = stopListEntityOptional .orElseGet(() -> { TppStopListEntity entity = new TppStopListEntity(); entity.setTppAuthorisationNumber(tppAuthorisationNumber); entity.setInstanceId(instanceId); return entity; }); entityToBeBlocked.block(lockPeriod); return true; }  @NotNull @Override Optional<TppStopListRecord> getTppStopListRecord(@NotNull String tppAuthorisationNumber, @NotNull String instanceId); @Transactional @Override boolean blockTpp(@NotNull String tppAuthorisationNumber, @NotNull String instanceId, @Nullable Duration lockPeriod); @Transactional @Override boolean unblockTpp(@NotNull String tppAuthorisationNumber, @NotNull String instanceId); @NotNull @Override Optional<TppInfo> getTppInfo(@NotNull String tppAuthorisationNumber, @NotNull String instanceId);  }### Answer:
@Test void blockTpp_Success_TppEntityIsExistInDB() { when(stopListRepository.findByTppAuthorisationNumberAndInstanceId(AUTHORISATION_NUMBER, INSTANCE_ID)) .thenReturn(Optional.of(tppStopListEntity)); doNothing() .when(tppStopListEntity).block(BLOCKING_DURATION); boolean isBlocked = cmsAspspTppService.blockTpp(AUTHORISATION_NUMBER, INSTANCE_ID, BLOCKING_DURATION); assertTrue(isBlocked); }
@Test void blockTpp_Success_TppEntityIsNotExistInDB() { when(stopListRepository.findByTppAuthorisationNumberAndInstanceId(AUTHORISATION_NUMBER_NOT_EXISTING, INSTANCE_ID)) .thenReturn(Optional.empty()); boolean isBlocked = cmsAspspTppService.blockTpp(AUTHORISATION_NUMBER_NOT_EXISTING, INSTANCE_ID, null); assertTrue(isBlocked); }