Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
[#141] add integration repository test
Browse files Browse the repository at this point in the history
  • Loading branch information
jenarp committed Jan 24, 2022
1 parent ee9568b commit 05d9085
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/test/java/de/bonndan/nivio/appuser/AppUserRepositoryTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package de.bonndan.nivio.appuser;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;

import java.util.Optional;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@DataJpaTest
class AppUserRepositoryTest {

@Autowired
private AppUserRepository appUserRepository;

@Test
void findByExternalId() {
Optional<AppUser> appUser = Optional.of(new AppUser());
appUser.get().setExternalId("100");
appUser.get().setAlias("login");
appUser.get().setAppUserRole(AppUserRole.USER);
appUser.get().setId(1L);
appUser.get().setIdp("github");

appUser.ifPresent(user -> appUserRepository.save(user));
final Optional<AppUser> fetchedAppUser = appUserRepository.findByExternalId(appUser.get().getExternalId());

assertNotNull(appUser);

assertThat(fetchedAppUser)
.hasValueSatisfying(fetched -> {
assertThat(fetched.getExternalId()).isNotNull().isEqualTo(appUser.get().getExternalId());
assertThat(fetched.getAlias()).isNotNull().isEqualTo(appUser.get().getAlias());
assertThat(fetched.getId()).isNotNull().isEqualTo(appUser.get().getId());
assertThat(fetched.getIdp()).isNotNull().isEqualTo(appUser.get().getIdp());
assertThat(fetched.getAppUserRole()).isNotNull().isEqualTo(appUser.get().getAppUserRole());

});
}
}

0 comments on commit 05d9085

Please sign in to comment.