package com.izouma.dingdong.service;

import com.izouma.dingdong.domain.rider.Rider;
import com.izouma.dingdong.dto.RiderDTO;
import com.izouma.dingdong.repo.rider.RiderRepo;
import com.izouma.dingdong.service.rider.RiderService;
import com.izouma.dingdong.web.rider.RiderController;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class RiderServiceTest {

    @Autowired
    private RiderService    riderService;
    @Autowired
    private RiderController riderController;

    @Test
    public void test() {

        String encode = new BCryptPasswordEncoder().encode("123456");
        String str = "123456";
        System.out.println(new BCryptPasswordEncoder().matches(str, encode));
//        System.out.println(RandomStringUtils.randomAlphabetic(1));
//        System.out.println(RandomStringUtils.randomNumeric(4));
    }

    @Test
    public void test1() {
        RiderDTO build = RiderDTO.builder()
                .area("国家广告园")
                .latitude(31.981746)
                .longitude(118.734661)
                .userId(151L)
                .build();
        System.out.println(riderService.riderApply(build));
//        System.out.println(riderRepo.findByUserId(151L).isPresent());
    }

    @Test
    public void test2() {
        Rider rider = Rider.builder()
                .newNews(false)
                .userId(2105L)
                .build();
        System.out.println(riderController.save(rider));
    }

}
