77import org .couchbase .quickstart .configs .CollectionNames ;
88import org .couchbase .quickstart .configs .DBProperties ;
99import org .couchbase .quickstart .models .Profile ;
10+ import org .couchbase .quickstart .models .ProfileRequest ;
1011import org .couchbase .quickstart .models .ProfileResult ;
1112
1213import org .hamcrest .MatcherAssert ;
@@ -57,7 +58,7 @@ public void cleanDB() {
5758 public void testUserProfileNotFound () {
5859
5960 this .webTestClient .get ()
60- .uri ("/api/v1/profiles ?limit=5&skip=0&searchFirstName=Bob" )
61+ .uri ("/api/v1/profile ?limit=5&skip=0&searchFirstName=Bob" )
6162 .accept (MediaType .APPLICATION_JSON )
6263 .exchange ()
6364 .expectStatus ().is4xxClientError ()
@@ -67,12 +68,12 @@ public void testUserProfileNotFound() {
6768 @ Test
6869 public void testCreateUserProfile (){
6970 //test data
70- Profile testProfile = getTestProfile ();
71- String json = getCreatedUserJson (testProfile );
71+ ProfileRequest createTestProfile = getCreateTestProfile ();
72+ String json = getCreatedUserJson (createTestProfile );
7273
7374 //run the post test
7475 EntityExchangeResult <ProfileResult > profileResult = this .webTestClient .post ()
75- .uri ("/api/v1/profiles /" )
76+ .uri ("/api/v1/profile /" )
7677 .bodyValue (json )
7778 .accept (MediaType .APPLICATION_JSON )
7879 .header ("Content-Type" , "application/json; charset=utf-8" )
@@ -85,10 +86,10 @@ public void testCreateUserProfile(){
8586 .get (profileResult .getResponseBody ().getPid ())
8687 .contentAs (Profile .class );
8788
88- assertEquals (result .getFirstName (), testProfile .getFirstName ());
89- assertEquals (result .getLastName (), testProfile .getLastName ());
90- assertEquals (result .getEmail (), testProfile .getEmail ());
91- assertNotEquals (result .getPassword (), testProfile .getPassword ());
89+ assertEquals (result .getFirstName (), createTestProfile .getFirstName ());
90+ assertEquals (result .getLastName (), createTestProfile .getLastName ());
91+ assertEquals (result .getEmail (), createTestProfile .getEmail ());
92+ assertNotEquals (result .getPassword (), createTestProfile .getPassword ());
9293 assertNotNull (result .getPid ());
9394 }
9495
@@ -101,7 +102,7 @@ public void testListUsersSuccess() {
101102 bucket .collection (CollectionNames .PROFILE ).insert (testProfile .getPid (), testProfile );
102103
103104 EntityExchangeResult <List <Profile >> profileListResult = this .webTestClient .get ()
104- .uri ("/api/v1/profiles /?limit=5&skip=0&searchFirstName=Jam" )
105+ .uri ("/api/v1/profile /?limit=5&skip=0&searchFirstName=Jam" )
105106 .accept (MediaType .APPLICATION_JSON )
106107 .exchange ()
107108 .expectStatus ().isOk ()
@@ -128,7 +129,7 @@ public void testListUsersNoResult() {
128129 bucket .collection (CollectionNames .PROFILE ).insert (testProfile .getPid (), testProfile );
129130
130131 EntityExchangeResult <List <Profile >> profileListResult = this .webTestClient .get ()
131- .uri ("/api/v1/profiles /?limit=5&skip=0&searchFirstName=Jack" )
132+ .uri ("/api/v1/profile /?limit=5&skip=0&searchFirstName=Jack" )
132133 .accept (MediaType .APPLICATION_JSON )
133134 .exchange ()
134135 .expectStatus ().isOk ()
@@ -151,7 +152,7 @@ public void testDeleteUserProfile() {
151152
152153 //delete the user
153154 this .webTestClient .delete ()
154- .uri (String .format ("/api/v1/profiles /%s" , testProfile .getPid ()))
155+ .uri (String .format ("/api/v1/profile /%s" , testProfile .getPid ()))
155156 .accept (MediaType .APPLICATION_JSON )
156157 .header ("Content-Type" , "application/json; charset=utf-8" )
157158 .exchange ()
@@ -160,7 +161,7 @@ public void testDeleteUserProfile() {
160161 bucket .collection (CollectionNames .PROFILE ).get (testProfile .getPid ());
161162 }
162163
163- private String getCreatedUserJson (Profile profile ) {
164+ private String getCreatedUserJson (ProfileRequest profile ) {
164165 //create json to post to integration test
165166 return JsonObject .create ()
166167 .put ("firstName" , profile .getFirstName ())
@@ -169,6 +170,14 @@ private String getCreatedUserJson(Profile profile) {
169170 .put ("email" , profile .getEmail ()).toString ();
170171 }
171172
173+ private ProfileRequest getCreateTestProfile () {
174+ return new ProfileRequest (
175+ "James" ,
176+ "Gosling" ,
177+ "password" ,
178+ 179+ }
180+
172181 private Profile getTestProfile () {
173182 return new Profile (
174183 UUID .randomUUID ().toString (),
0 commit comments