UserRepositoryTests.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2002-2017 the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package sample;
  17. import org.junit.Test;
  18. import org.junit.runner.RunWith;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.test.context.ContextConfiguration;
  21. import org.springframework.test.context.TestPropertySource;
  22. import org.springframework.test.context.junit4.SpringRunner;
  23. import static org.assertj.core.api.Assertions.assertThat;
  24. /**
  25. *
  26. * @author Rob Winch
  27. * @since 5.0
  28. */
  29. @SuppressWarnings("unused")
  30. @RunWith(SpringRunner.class)
  31. @ContextConfiguration(classes = Application.class)
  32. @TestPropertySource(properties = "server.port=0")
  33. public class UserRepositoryTests {
  34. @Autowired UserRepository repository;
  35. String robUsername = "rob";
  36. @Test
  37. public void findByUsernameWhenUsernameMatchesThenFound() {
  38. assertThat(repository.findByUsername(this.robUsername).block()).isNotNull();
  39. }
  40. @Test
  41. public void findByUsernameWhenUsernameDoesNotMatchThenFound() {
  42. assertThat(repository.findByUsername(this.robUsername + "NOTFOUND").block()).isNull();
  43. }
  44. }