Commit 2db688aa19390694fc734be3e402a417c421fc09

Authored by Thomas Ziemer
1 parent fcd0cdd7

test: bisschen mehr Inhalt (WIP)

... ... @@ -19,6 +19,7 @@
19 19 <mockito-version>2.7.22</mockito-version>
20 20 <dbunit-version>2.5.1</dbunit-version>
21 21 <slf4j-version>1.7.25</slf4j-version>
  22 + <jglue-version>3.1.4</jglue-version>
22 23 <jackson-version>2.8.8.1</jackson-version>
23 24  
24 25 <!-- Substituiert die Platzhalter in der "persistence.xml" -->
... ... @@ -80,6 +81,11 @@
80 81 <artifactId>mysql-connector-java</artifactId>
81 82 <version>${mysql-version}</version>
82 83 </dependency>
  84 + <dependency>
  85 + <groupId>org.jglue.cdi-unit</groupId>
  86 + <artifactId>cdi-unit</artifactId>
  87 + <version>${jglue-version}</version>
  88 + </dependency>
83 89 <!-- dependency>
84 90 <groupId>com.fasterxml.jackson.core</groupId>
85 91 <artifactId>jackson-databind</artifactId>
... ...
src/main/java/net/ziemers/swxercise/lg/user/dto/UserDto.java
... ... @@ -40,12 +40,27 @@ public class UserDto {
40 40 return firstname;
41 41 }
42 42  
  43 + public UserDto withFirstname(final String firstname) {
  44 + this.firstname = firstname;
  45 + return this;
  46 + }
  47 +
43 48 public String getLastname() {
44 49 return lastname;
45 50 }
46 51  
  52 + public UserDto withLastname(final String lastname) {
  53 + this.lastname = lastname;
  54 + return this;
  55 + }
  56 +
47 57 public String getMailaddress() {
48 58 return mailaddress;
49 59 }
50 60  
  61 + public UserDto withMailaddress(final String mailaddress) {
  62 + this.mailaddress = mailaddress;
  63 + return this;
  64 + }
  65 +
51 66 }
... ...
src/test/java/net/ziemers/swxercise/lg/user/service/UserServiceTest.java
1 1 package net.ziemers.swxercise.lg.user.service;
2 2  
  3 +import javax.inject.Inject;
  4 +
3 5 import net.ziemers.swxercise.db.utils.JpaTestUtils;
4 6 import net.ziemers.swxercise.lg.model.user.User;
  7 +import net.ziemers.swxercise.lg.user.dto.UserDto;
  8 +import net.ziemers.swxercise.lg.user.service.UserService;
  9 +
  10 +import org.jglue.cdiunit.CdiRunner;
5 11 import org.junit.Before;
6 12 import org.junit.Test;
  13 +import org.junit.runner.RunWith;
  14 +import org.mockito.Mock;
7 15  
  16 +@RunWith(CdiRunner.class)
8 17 public class UserServiceTest extends JpaTestUtils {
9 18  
10 19 private static boolean dbInitialized;
11 20  
  21 + @Inject
  22 + private UserService underTest;
  23 +
12 24 @Before
13 25 public void setup() throws Exception {
14 26 if (!dbInitialized) {
... ... @@ -21,7 +33,15 @@ public class UserServiceTest extends JpaTestUtils {
21 33 @Test
22 34 public void testService() {
23 35 txBegin();
24   - getEm().persist(new User("Hein", "Blöd"));
  36 +
  37 + final UserDto dto = new UserDto()
  38 + .withFirstname("Hein")
  39 + .withLastname("Blöd")
  40 + .withUsername("tziemer")
  41 + .withPassword("secret");
  42 +
  43 + //underTest.createUser(dto);
  44 +
25 45 txCommit();
26 46 }
27 47  
... ...