Browse Source

merging with Jaes register branch

Elliott Stansbury 5 years ago
parent
commit
5238999cf8

+ 2
- 2
.yo-rc.json View File

@@ -13,7 +13,7 @@
13 13
     "authenticationType": "jwt",
14 14
     "cacheProvider": "hazelcast",
15 15
     "enableHibernateCache": true,
16
-    "websocket": false,
16
+    "websocket": "spring-websocket",
17 17
     "databaseType": "sql",
18 18
     "devDatabaseType": "h2Memory",
19 19
     "prodDatabaseType": "postgresql",
@@ -35,4 +35,4 @@
35 35
       "en"
36 36
     ]
37 37
   }
38
-}
38
+}

+ 4
- 0
src/main/java/rocks/zipcode/io/repository/UserRepository.java View File

@@ -1,5 +1,6 @@
1 1
 package rocks.zipcode.io.repository;
2 2
 
3
+import org.springframework.data.jpa.repository.Query;
3 4
 import rocks.zipcode.io.domain.User;
4 5
 
5 6
 import org.springframework.cache.annotation.Cacheable;
@@ -32,6 +33,9 @@ public interface UserRepository extends JpaRepository<User, Long> {
32 33
 
33 34
     Optional<User> findOneByLogin(String login);
34 35
 
36
+    @Query("select user from User user where user.login = ?#{principal.username}")
37
+    Optional<User> findOneByCurrentUser();
38
+
35 39
     @EntityGraph(attributePaths = "authorities")
36 40
     Optional<User> findOneWithAuthoritiesById(Long id);
37 41
 

+ 30
- 1
src/main/java/rocks/zipcode/io/service/UserService.java View File

@@ -1,10 +1,13 @@
1 1
 package rocks.zipcode.io.service;
2 2
 
3 3
 import rocks.zipcode.io.config.Constants;
4
+import rocks.zipcode.io.domain.AccountDetails;
4 5
 import rocks.zipcode.io.domain.Authority;
5 6
 import rocks.zipcode.io.domain.Profile;
6 7
 import rocks.zipcode.io.domain.User;
8
+import rocks.zipcode.io.repository.AccountDetailsRepository;
7 9
 import rocks.zipcode.io.repository.AuthorityRepository;
10
+import rocks.zipcode.io.repository.ProfileRepository;
8 11
 import rocks.zipcode.io.repository.UserRepository;
9 12
 import rocks.zipcode.io.security.AuthoritiesConstants;
10 13
 import rocks.zipcode.io.security.SecurityUtils;
@@ -38,17 +41,23 @@ public class UserService {
38 41
 
39 42
     private final UserRepository userRepository;
40 43
 
44
+    private final ProfileRepository profileRepository;
45
+
46
+    private final AccountDetailsRepository accountDetailsRepository;
47
+
41 48
     private final PasswordEncoder passwordEncoder;
42 49
 
43 50
     private final AuthorityRepository authorityRepository;
44 51
 
45 52
     private final CacheManager cacheManager;
46 53
 
47
-    public UserService(UserRepository userRepository, PasswordEncoder passwordEncoder, AuthorityRepository authorityRepository, CacheManager cacheManager) {
54
+    public UserService(UserRepository userRepository, AccountDetailsRepository accountDetailsRepository, ProfileRepository profileRepository, PasswordEncoder passwordEncoder, AuthorityRepository authorityRepository, CacheManager cacheManager) {
48 55
         this.userRepository = userRepository;
49 56
         this.passwordEncoder = passwordEncoder;
50 57
         this.authorityRepository = authorityRepository;
51 58
         this.cacheManager = cacheManager;
59
+        this.profileRepository = profileRepository;
60
+        this.accountDetailsRepository = accountDetailsRepository;
52 61
     }
53 62
 
54 63
     public Optional<User> activateRegistration(String key) {
@@ -140,6 +149,18 @@ public class UserService {
140 149
         user.setLastName(userDTO.getLastName());
141 150
         user.setEmail(userDTO.getEmail().toLowerCase());
142 151
         user.setImageUrl(userDTO.getImageUrl());
152
+
153
+        //create default profile
154
+        Profile profile = new Profile();
155
+        profile.setBio("");
156
+        profile.setUserProfile(user);
157
+        profile.setAccessible(true);
158
+
159
+        //create default account details
160
+        AccountDetails accountDetails = new AccountDetails();
161
+        accountDetails.setSecurityQuestion("");
162
+        accountDetails.setSecurityAnswer("");
163
+
143 164
         if (userDTO.getLangKey() == null) {
144 165
             user.setLangKey(Constants.DEFAULT_LANGUAGE); // default language
145 166
         } else {
@@ -158,7 +179,15 @@ public class UserService {
158 179
                 .collect(Collectors.toSet());
159 180
             user.setAuthorities(authorities);
160 181
         }
182
+
161 183
         userRepository.save(user);
184
+
185
+        //save the default profile
186
+        profileRepository.save(profile);
187
+
188
+        //save the default account details
189
+        accountDetailsRepository.save(accountDetails);
190
+
162 191
         this.clearUserCaches(user);
163 192
         log.debug("Created Information for User: {}", user);
164 193
         return user;

+ 2
- 4
src/main/java/rocks/zipcode/io/web/rest/AccountResource.java View File

@@ -3,6 +3,7 @@ package rocks.zipcode.io.web.rest;
3 3
 import com.codahale.metrics.annotation.Timed;
4 4
 
5 5
 import rocks.zipcode.io.domain.User;
6
+import rocks.zipcode.io.repository.ProfileRepository;
6 7
 import rocks.zipcode.io.repository.UserRepository;
7 8
 import rocks.zipcode.io.security.SecurityUtils;
8 9
 import rocks.zipcode.io.service.MailService;
@@ -79,7 +80,6 @@ public class AccountResource {
79 80
         if (!user.isPresent()) {
80 81
             throw new InternalServerErrorException("No user was found for this activation key");
81 82
         }
82
-        System.out.println("2");
83 83
     }
84 84
 
85 85
     /**
@@ -130,9 +130,7 @@ public class AccountResource {
130 130
         if (!user.isPresent()) {
131 131
             throw new InternalServerErrorException("User could not be found");
132 132
         }
133
-        userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
134
-            userDTO.getLangKey(), userDTO.getImageUrl());
135
-        System.out.println("5");
133
+        userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(), userDTO.getLangKey(), userDTO.getImageUrl());
136 134
     }
137 135
 
138 136
     /**

+ 7
- 2
src/main/java/rocks/zipcode/io/web/rest/PostResource.java View File

@@ -3,6 +3,7 @@ package rocks.zipcode.io.web.rest;
3 3
 import com.codahale.metrics.annotation.Timed;
4 4
 import rocks.zipcode.io.domain.Post;
5 5
 import rocks.zipcode.io.repository.PostRepository;
6
+import rocks.zipcode.io.repository.UserRepository;
6 7
 import rocks.zipcode.io.web.rest.errors.BadRequestAlertException;
7 8
 import rocks.zipcode.io.web.rest.util.HeaderUtil;
8 9
 import io.github.jhipster.web.util.ResponseUtil;
@@ -30,8 +31,11 @@ public class PostResource {
30 31
 
31 32
     private final PostRepository postRepository;
32 33
 
33
-    public PostResource(PostRepository postRepository) {
34
+    private final UserRepository userRepository;
35
+
36
+    public PostResource(PostRepository postRepository, UserRepository userRepository) {
34 37
         this.postRepository = postRepository;
38
+        this.userRepository = userRepository;
35 39
     }
36 40
 
37 41
     /**
@@ -44,6 +48,7 @@ public class PostResource {
44 48
     @PostMapping("/posts")
45 49
     @Timed
46 50
     public ResponseEntity<Post> createPost(@RequestBody Post post) throws URISyntaxException {
51
+        post.setOwner(userRepository.findOneByCurrentUser().get());
47 52
         log.debug("REST request to save Post : {}", post);
48 53
         if (post.getId() != null) {
49 54
             throw new BadRequestAlertException("A new post cannot already have an ID", ENTITY_NAME, "idexists");
@@ -85,7 +90,7 @@ public class PostResource {
85 90
     @Timed
86 91
     public List<Post> getAllPosts() {
87 92
         log.debug("REST request to get all Posts");
88
-        return postRepository.findAll();
93
+        return postRepository.findByOwnerIsCurrentUser();
89 94
     }
90 95
 
91 96
     /**

+ 1
- 0
src/main/resources/.h2.server.properties View File

@@ -1,4 +1,5 @@
1 1
 #H2 Server Properties
2
+#Wed Jan 09 09:38:54 EST 2019
2 3
 0=JHipster H2 (Memory)|org.h2.Driver|jdbc\:h2\:mem\:faeboo|FaeBoo
3 4
 webAllowOthers=true
4 5
 webPort=8082

+ 79
- 0
src/main/webapp/app/FaeBoo/Profile-head/profile-head.component.html View File

@@ -0,0 +1,79 @@
1
+<div class="main-cont">
2
+
3
+    <div class = "friend-cont">
4
+
5
+        <div class="friend-pic friend4" id = "friend7">
6
+            <img class ="friend-photo friend4" src = "../../../content/images/defaultphoto.png">
7
+        </div>
8
+
9
+        <div class="friend-pic friend3" id = "friend5">
10
+            <img class ="friend-photo friend3" src = "../../../content/images/defaultphoto.png">
11
+        </div>
12
+
13
+        <div class="friend-pic friend2" id = "friend3">
14
+            <img class ="friend-photo" src = "../../../content/images/defaultphoto.png">
15
+        </div>
16
+
17
+        <div class="friend-pic friend1" id = "friend1">
18
+            <img class ="friend-photo" src = "../../../content/images/defaultphoto.png">
19
+        </div>
20
+
21
+        <div class = "profile-pic">
22
+            <img class ="friend-photo" src = "../../../content/images/defaultphoto.png">
23
+        </div>
24
+
25
+        <div class="friend-pic friend1" id = "friend2">
26
+            <img class ="friend-photo" src = "../../../content/images/defaultphoto.png">
27
+        </div>
28
+
29
+        <div class="friend-pic friend2" id = "friend4">
30
+            <img class ="friend-photo" src = "../../../content/images/defaultphoto.png">
31
+        </div>
32
+
33
+        <div class="friend-pic friend3" id = "friend6">
34
+            <img class ="friend-photo" src = "../../../content/images/defaultphoto.png">
35
+        </div>
36
+
37
+        <div class="friend-pic friend4" id = friend8>
38
+            <img class ="friend-photo" src = "../../../content/images/defaultphoto.png">
39
+        </div>
40
+
41
+    </div>
42
+
43
+
44
+    <div class = "settings-container">
45
+
46
+        <button>Settings</button>
47
+        <button>Change Profile</button>
48
+        <button>Change Bio</button>
49
+        <button>Friends</button>
50
+
51
+    </div>
52
+
53
+    <hr>
54
+
55
+    <div id = "bio-cont"></div>
56
+
57
+    <hr>
58
+
59
+    <div id = "feed">
60
+
61
+        <div class = "post">
62
+            <div>
63
+                <textarea id = "post-area" [(ngModel)]="str"></textarea>
64
+            </div>
65
+
66
+            <div id = "postButton-container">
67
+                <div class = "button-holder"><button class = "postBtn">Schedule</button></div>
68
+                <div class = "button-holder"><button class = "postBtn">Memo</button></div>
69
+                <div class = "button-holder"><button class = "postBtn">Photo</button></div>
70
+                <div class = "button-holder"><button class = "postBtn" (click)="submitPost();">Submit</button></div>
71
+            </div>
72
+
73
+            <p id = "msg">Create a post...</p>
74
+        </div>
75
+
76
+
77
+    </div>
78
+
79
+</div>

+ 51
- 2
src/main/webapp/app/FaeBoo/Profile-head/profile-head.component.ts View File

@@ -1,8 +1,57 @@
1 1
 import { Component } from '@angular/core';
2
+import { PostService } from 'app/entities/post';
3
+import { IPost } from 'app/shared/model/post.model';
4
+import { IUser } from 'app/core';
5
+import { Observable } from 'rxjs';
6
+import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
2 7
 
3 8
 @Component({
4 9
     selector: 'jhi-profile-head',
5 10
     templateUrl: './profile-head.component.html',
6
-    styleUrls: ['profile-head.scss']
11
+    styleUrls: ['profile-head.css']
7 12
 })
8
-export class ProfileHeadComponent {}
13
+export class ProfileHeadComponent {
14
+    str: string;
15
+    post: IPost;
16
+    user: IUser;
17
+    isSaving: boolean;
18
+    testPost: IPost;
19
+
20
+    constructor(private postService: PostService) {}
21
+
22
+    submitPost(): void {
23
+        this.post = new class implements IPost {
24
+            content: string;
25
+            dislikes: number;
26
+            id: number;
27
+            likes: number;
28
+            numberOfComments: number;
29
+            owner: IUser;
30
+        }();
31
+        this.post.content = this.str;
32
+        this.post.dislikes = 0;
33
+        this.post.likes = 0;
34
+        this.post.numberOfComments = 0;
35
+        if (this.post.content.length > 1) {
36
+            this.save(this.post);
37
+        }
38
+    }
39
+
40
+    save(post: IPost) {
41
+        this.isSaving = true;
42
+        this.subscribeToSaveResponse(this.postService.create(post));
43
+        console.log('post created');
44
+    }
45
+
46
+    private subscribeToSaveResponse(result: Observable<HttpResponse<IPost>>) {
47
+        result.subscribe((res: HttpResponse<IPost>) => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError());
48
+    }
49
+
50
+    private onSaveSuccess() {
51
+        this.isSaving = false;
52
+    }
53
+
54
+    private onSaveError() {
55
+        this.isSaving = false;
56
+    }
57
+}

+ 160
- 0
src/main/webapp/app/FaeBoo/Profile-head/profile-head.css View File

@@ -0,0 +1,160 @@
1
+.main-cont {
2
+    width: 100%;
3
+    height: 1fr;
4
+    box-sizing: border-box;
5
+    padding: 8px;
6
+    position: relative;
7
+}
8
+
9
+.friend-cont {
10
+    display: grid;
11
+    justify-items: center;
12
+    grid-template-columns: calc(10%) calc(10%) calc(10%) calc(10%) calc(20%) calc(10%) calc(10%) calc(10%) calc(10%);
13
+    /*grid-column-gap: 5px;*/
14
+    grid-template-rows: auto;
15
+    width: 100%;
16
+    height: 100%;
17
+    box-sizing: border-box;
18
+    position: relative;
19
+    overflow-y: auto;
20
+    overflow-x: scroll;
21
+    margin: auto;
22
+}
23
+
24
+#bio-cont {
25
+    width: 100%;
26
+    height: 75px;
27
+    box-sizing: border-box;
28
+    padding: 8px;
29
+    margin-top: 8px;
30
+}
31
+
32
+.friend-pic {
33
+    width: 100px;
34
+    height: 100px;
35
+    position: relative;
36
+    border-radius: 50%;
37
+    margin: auto;
38
+    overflow-x: hidden;
39
+}
40
+
41
+.friend-photo {
42
+    width: 100%;
43
+    height: 100%;
44
+    object-fit: cover;
45
+}
46
+
47
+.profile-pic {
48
+    width: 200px;
49
+    height: 200px;
50
+    position: relative;
51
+    overflow: hidden;
52
+    border-radius: 50%;
53
+    grid-column-start: 5;
54
+    grid-row-start: 1;
55
+    margin: auto;
56
+    z-index: 5;
57
+}
58
+
59
+.friend1 {
60
+    z-index: 1;
61
+}
62
+
63
+.friend2 {
64
+    z-index: 2;
65
+}
66
+
67
+.friend3 {
68
+    z-index: 3;
69
+}
70
+
71
+.friend4 {
72
+    z-index: 4;
73
+}
74
+
75
+.settings-container {
76
+    width: 100%;
77
+    text-align: center;
78
+    padding: 10px;
79
+}
80
+
81
+.settings-container button {
82
+    display: inline-block;
83
+    width: 20%;
84
+    text-align: center;
85
+    border: none;
86
+    background-color: #e2e6eb;
87
+    padding: 5px;
88
+    color: #969a9f;
89
+    margin-right: 10px;
90
+    margin-top: 10px;
91
+}
92
+
93
+hr {
94
+    border: 1px solid #d1d5da;
95
+}
96
+
97
+#feed {
98
+    width: 65%;
99
+    min-height: 250px;
100
+    margin: auto;
101
+    padding: 10px;
102
+    box-sizing: border-box;
103
+}
104
+
105
+.post {
106
+    width: 100%;
107
+    height: 245px;
108
+    padding: 15px;
109
+    box-sizing: border-box;
110
+    display: grid;
111
+    grid-template-columns: calc(85% - 5px) 15%;
112
+    grid-template-rows: 195px 20px;
113
+    grid-column-gap: 5px;
114
+    color: #969a9f;
115
+    border-radius: 5px;
116
+    background-color: #e2e6eb;
117
+}
118
+
119
+#post-area {
120
+    resize: none;
121
+    width: 100%;
122
+    height: 100%;
123
+    grid-row-start: 1;
124
+    grid-column-start: 1;
125
+    border: none;
126
+    border-radius: 5px;
127
+    padding: 10px;
128
+}
129
+
130
+#postButton-container {
131
+    width: 100%;
132
+    height: 100%;
133
+    display: grid;
134
+    grid-template-rows: 25% 25% 25% 25%;
135
+    grid-template-columns: 100%;
136
+    box-sizing: border-box;
137
+    grid-row-start: 1;
138
+    grid-column-start: 2;
139
+}
140
+
141
+.postBtn {
142
+    width: 100%;
143
+    height: 100%;
144
+    font-size: 10px;
145
+    border: none;
146
+    background-color: white;
147
+    color: #969a9f;
148
+}
149
+
150
+.button-holder {
151
+    width: 100%;
152
+    height: 100%;
153
+    box-sizing: border-box;
154
+    padding: 5px;
155
+}
156
+
157
+#msg {
158
+    grid-column-start: 1;
159
+    grid-row-start: 2;
160
+}

+ 0
- 0
src/main/webapp/app/FaeBoo/Profile-head/profile-head.scss View File


+ 1
- 0
src/main/webapp/app/FaeBoo/Profile-temp/profile-temp.component.html View File

@@ -0,0 +1 @@
1
+<jhi-profile-head></jhi-profile-head>

+ 1
- 0
src/main/webapp/app/FaeBoo/Profile-temp/profile-temp.component.ts View File

@@ -1,4 +1,5 @@
1 1
 import { Component } from '@angular/core';
2
+import { ProfileHeadComponent } from 'app/FaeBoo/Profile-head/profile-head.component';
2 3
 
3 4
 @Component({
4 5
     selector: 'jhi-profile-temp',

+ 2
- 1
src/main/webapp/app/FaeBoo/Profile-temp/profile-temp.module.ts View File

@@ -4,10 +4,11 @@ import { RouterModule } from '@angular/router';
4 4
 import { FaeBooSharedModule } from 'app/shared';
5 5
 import { PROFILE_ROUTE } from 'app/FaeBoo/Profile-temp/profile-temp.route';
6 6
 import { ProfileTempComponent } from 'app/FaeBoo/Profile-temp/profile-temp.component';
7
+import { ProfileHeadComponent } from 'app/FaeBoo/Profile-head/profile-head.component';
7 8
 
8 9
 @NgModule({
9 10
     imports: [FaeBooSharedModule, RouterModule.forChild([PROFILE_ROUTE])],
10
-    declarations: [ProfileTempComponent],
11
+    declarations: [ProfileTempComponent, ProfileHeadComponent],
11 12
     schemas: [CUSTOM_ELEMENTS_SCHEMA]
12 13
 })
13 14
 export class ProfileTempModule {}

+ 39
- 0
src/main/webapp/app/FaeBoo/Services/post.service.ts View File

@@ -0,0 +1,39 @@
1
+import { Injectable } from '@angular/core';
2
+import { HttpClient, HttpResponse } from '@angular/common/http';
3
+import { Observable } from 'rxjs';
4
+
5
+import { SERVER_API_URL } from 'app/app.constants';
6
+import { createRequestOption } from 'app/shared/util/request-util';
7
+import { IPost } from 'app/shared/model/post.model';
8
+
9
+@Injectable({ providedIn: 'root' })
10
+export class PostService {
11
+    public resourceUrl = SERVER_API_URL + 'api/users';
12
+
13
+    constructor(private http: HttpClient) {}
14
+
15
+    create(post: IPost): Observable<HttpResponse<IPost>> {
16
+        return this.http.post<IPost>(this.resourceUrl, post, { observe: 'response' });
17
+    }
18
+
19
+    update(post: IPost): Observable<HttpResponse<IPost>> {
20
+        return this.http.put<IPost>(this.resourceUrl, post, { observe: 'response' });
21
+    }
22
+
23
+    find(login: string): Observable<HttpResponse<IPost>> {
24
+        return this.http.get<IPost>(`${this.resourceUrl}/${login}`, { observe: 'response' });
25
+    }
26
+
27
+    query(req?: any): Observable<HttpResponse<IPost[]>> {
28
+        const options = createRequestOption(req);
29
+        return this.http.get<IPost[]>(this.resourceUrl, { params: options, observe: 'response' });
30
+    }
31
+
32
+    delete(login: string): Observable<HttpResponse<any>> {
33
+        return this.http.delete(`${this.resourceUrl}/${login}`, { observe: 'response' });
34
+    }
35
+
36
+    authorities(): Observable<string[]> {
37
+        return this.http.get<string[]>(SERVER_API_URL + 'api/users/authorities');
38
+    }
39
+}

+ 1
- 0
src/main/webapp/app/account/register/register.component.ts View File

@@ -39,6 +39,7 @@ export class RegisterComponent implements OnInit, AfterViewInit {
39 39
     }
40 40
 
41 41
     register() {
42
+        console.log('Register');
42 43
         if (this.registerAccount.password !== this.confirmPassword) {
43 44
             this.doNotMatch = 'ERROR';
44 45
         } else {

+ 3
- 3
src/main/webapp/app/app.module.ts View File

@@ -7,7 +7,7 @@ import { NgbDatepickerConfig } from '@ng-bootstrap/ng-bootstrap';
7 7
 import { Ng2Webstorage } from 'ngx-webstorage';
8 8
 import { NgJhipsterModule } from 'ng-jhipster';
9 9
 
10
-import { ProfileHeadComponent } from 'app/FaeBoo/Profile-head/profile-head.component';
10
+// import { ProfileHeadComponent } from 'app/FaeBoo/Profile-head/profile-head.component';
11 11
 import { ProfileTempComponent } from 'app/FaeBoo/Profile-temp/profile-temp.component';
12 12
 import { ProfileTempModule } from 'app/FaeBoo/Profile-temp/profile-temp.module';
13 13
 
@@ -51,8 +51,8 @@ import { JhiMainComponent, NavbarComponent, FooterComponent, PageRibbonComponent
51 51
         ErrorComponent,
52 52
         PageRibbonComponent,
53 53
         ActiveMenuDirective,
54
-        FooterComponent,
55
-        ProfileHeadComponent
54
+        FooterComponent
55
+        // ProfileHeadComponent,
56 56
     ],
57 57
     providers: [
58 58
         {

+ 0
- 1
src/main/webapp/app/layouts/navbar/navbar.component.ts View File

@@ -79,5 +79,4 @@ export class NavbarComponent implements OnInit {
79 79
     getImageUrl() {
80 80
         return this.isAuthenticated() ? this.principal.getImageUrl() : null;
81 81
     }
82
-    /*some change*/
83 82
 }

BIN
src/main/webapp/content/images/defaultphoto.png View File


+ 5
- 1
src/test/java/rocks/zipcode/io/web/rest/PostResourceIntTest.java View File

@@ -4,6 +4,7 @@ import rocks.zipcode.io.FaeBooApp;
4 4
 
5 5
 import rocks.zipcode.io.domain.Post;
6 6
 import rocks.zipcode.io.repository.PostRepository;
7
+import rocks.zipcode.io.repository.UserRepository;
7 8
 import rocks.zipcode.io.web.rest.errors.ExceptionTranslator;
8 9
 
9 10
 import org.junit.Before;
@@ -55,6 +56,9 @@ public class PostResourceIntTest {
55 56
     private PostRepository postRepository;
56 57
 
57 58
     @Autowired
59
+    UserRepository userRepository;
60
+
61
+    @Autowired
58 62
     private MappingJackson2HttpMessageConverter jacksonMessageConverter;
59 63
 
60 64
     @Autowired
@@ -73,7 +77,7 @@ public class PostResourceIntTest {
73 77
     @Before
74 78
     public void setup() {
75 79
         MockitoAnnotations.initMocks(this);
76
-        final PostResource postResource = new PostResource(postRepository);
80
+        final PostResource postResource = new PostResource(postRepository, userRepository);
77 81
         this.restPostMockMvc = MockMvcBuilders.standaloneSetup(postResource)
78 82
             .setCustomArgumentResolvers(pageableArgumentResolver)
79 83
             .setControllerAdvice(exceptionTranslator)