Skip to content

Commit 07f1e25

Browse files
author
Holly Williams
committed
fixed per pr comments
1 parent 3253b68 commit 07f1e25

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

send-surveys/src/main/java/com/objectcomputing/pulsesurvey/receive/responses/SurveyResponseController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ public HttpResponse sendThankYouWithCommentBlock (String userComments, String su
115115
LOG.info("With surveyKey: " + surveyKey);
116116
// put comment into the db using the survey key
117117

118-
boolean commentSaved = saveUserComment(surveyKey, userComments);
119-
LOG.info("commentSaved: " + commentSaved);
118+
saveUserComment(surveyKey, userComments);
120119

121120
return HttpResponse.ok();
122121
}
@@ -174,7 +173,7 @@ private boolean checkForComment(String surveyKey) {
174173

175174
}
176175

177-
boolean saveUserComment(String surveyKey, String comments) {
176+
void saveUserComment(String surveyKey, String comments) {
178177

179178
boolean commentsAdded = false;
180179
UserComments userComments = new UserComments();
@@ -186,7 +185,6 @@ boolean saveUserComment(String surveyKey, String comments) {
186185

187186
if (userComments.getCommentId() != null) commentsAdded = true;
188187

189-
return commentsAdded;
190188
}
191189

192190
ResponseKey markKeyAsUsed(String surveyKey) {

send-surveys/src/test/java/com/objectcomputing/pulsesurvey/receive/responses/SurveyResponseControllerTest.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.objectcomputing.pulsesurvey.receive.responses;
22

3-
import com.fasterxml.jackson.core.JsonProcessingException;
4-
import com.fasterxml.jackson.databind.ObjectMapper;
53
import com.objectcomputing.pulsesurvey.email.manager.GmailSender;
64
import com.objectcomputing.pulsesurvey.model.Response;
75
import com.objectcomputing.pulsesurvey.model.ResponseKey;
@@ -10,9 +8,7 @@
108
import com.objectcomputing.pulsesurvey.repositories.ResponseRepository;
119
import com.objectcomputing.pulsesurvey.repositories.UserCommentsRepository;
1210
import com.objectcomputing.pulsesurvey.send.surveys.SurveysControllerTest;
13-
import com.objectcomputing.pulsesurvey.template.manager.SurveyTemplateManager;
1411
import io.micronaut.core.io.buffer.ByteBuffer;
15-
import io.micronaut.core.util.CollectionUtils;
1612
import io.micronaut.http.HttpRequest;
1713
import io.micronaut.http.HttpResponse;
1814
import io.micronaut.http.HttpStatus;
@@ -28,18 +24,21 @@
2824
import org.slf4j.LoggerFactory;
2925

3026
import javax.inject.Inject;
31-
3227
import java.time.LocalDateTime;
3328
import java.time.Month;
3429
import java.util.HashMap;
3530
import java.util.Map;
3631
import java.util.Optional;
3732
import java.util.UUID;
3833

39-
import static org.junit.jupiter.api.Assertions.*;
34+
import static org.junit.jupiter.api.Assertions.assertEquals;
35+
import static org.junit.jupiter.api.Assertions.assertFalse;
36+
import static org.junit.jupiter.api.Assertions.assertTrue;
4037
import static org.mockito.ArgumentMatchers.any;
4138
import static org.mockito.Mockito.mock;
4239
import static org.mockito.Mockito.reset;
40+
import static org.mockito.Mockito.times;
41+
import static org.mockito.Mockito.verify;
4342
import static org.mockito.Mockito.when;
4443

4544
@ExtendWith(SystemPropertyExtension.class)
@@ -243,7 +242,8 @@ void testSaveUserComment() {
243242

244243
when(mockUserCommentsRepository.save(any())).thenReturn(fakeUserComments);
245244

246-
assertTrue(itemUnderTest.saveUserComment(surveyKey, fakeComments));
245+
itemUnderTest.saveUserComment(surveyKey, fakeComments);
246+
verify(mockUserCommentsRepository, times(1)).save(any(UserComments.class));
247247

248248
}
249249

@@ -267,10 +267,6 @@ void testSendThankYouWithCommentBlock() {
267267

268268
when(mockUserCommentsRepository.save(any())).thenReturn(fakeUserComments);
269269

270-
//todo should we just call this directly?
271-
// HttpResponse resp = itemUnderTest.sendThankYouWithCommentBlock(userComments, surveyKey);
272-
// assertEquals(HttpStatus.OK, resp.getStatus());
273-
274270
HttpResponse response = httpClient
275271
.exchange(HttpRequest.POST("/happiness/userComments", fakeBody)
276272
.contentType(MediaType.APPLICATION_FORM_URLENCODED))

0 commit comments

Comments
 (0)