@Test
  public void deleteParentCheck() {
    Set<Role> roles =
        Sets.newHashSet(
            roleRepository.save(
                Sets.newHashSet(
                    Role.builder().name("admin").build(),
                    Role.builder().name("verified").build(),
                    Role.builder().name("registered").build())));

    User parent =
        userRepository.save(
            User.builder()
                .accessToken("testAccessToken")
                .email("*****@*****.**")
                .name("testUser")
                .password("testPassword")
                .resetToken("testResetToken")
                .roles(roles)
                .build());

    Check parentCheck =
        checkRepository.save(
            Check.builder()
                .probe("testProbe")
                .interval(1)
                .name("testCheck")
                .state(State.ELECTED)
                .status(Status.UP)
                .user(parent)
                .url("http://www.test.com")
                .build());

    resultRepository.save(
        Result.builder()
            .probe("testProbe")
            .changed(true)
            .confirmation(true)
            .check(parentCheck)
            .responseTime(15)
            .status(Status.UP)
            .statusCode(200)
            .build());

    checkRepository.delete(parentCheck);
    List<Result> results = resultRepository.findByCheckId(parentCheck.getId(), null).getContent();
    Assert.assertTrue(results.isEmpty());
    userRepository.delete(parent);
  }
  @Test
  public void findByPrevious() {
    Set<Role> roles =
        Sets.newHashSet(
            roleRepository.save(
                Sets.newHashSet(
                    Role.builder().name("admin").build(),
                    Role.builder().name("verified").build(),
                    Role.builder().name("registered").build())));

    User parent =
        userRepository.save(
            User.builder()
                .accessToken("testAccessToken")
                .email("*****@*****.**")
                .name("testUser")
                .password("testPassword")
                .resetToken("testResetToken")
                .roles(roles)
                .build());

    Check parentCheck =
        checkRepository.save(
            Check.builder()
                .probe("testProbe")
                .interval(1)
                .name("testCheck")
                .state(State.ELECTED)
                .status(Status.UP)
                .user(parent)
                .url("http://www.test.com")
                .build());

    Result previousResult =
        resultRepository.save(
            Result.builder()
                .probe("testProbe")
                .changed(true)
                .confirmation(true)
                .check(parentCheck)
                .responseTime(15)
                .status(Status.UP)
                .statusCode(200)
                .build());

    Result result =
        resultRepository.save(
            Result.builder()
                .probe("testProbe")
                .changed(true)
                .confirmation(true)
                .check(parentCheck)
                .previous(previousResult)
                .responseTime(15)
                .status(Status.UP)
                .statusCode(200)
                .build());

    Result foundResult = resultRepository.findByPrevious(previousResult.getId()).get(0);
    Assert.assertEquals(result.getId(), foundResult.getId());
    userRepository.delete(parent);
  }