|
21 | 21 |
|
22 | 22 | import lombok.extern.slf4j.Slf4j; |
23 | 23 | import org.junit.jupiter.api.BeforeEach; |
24 | | -import org.junit.jupiter.api.Disabled; |
25 | 24 | import org.junit.jupiter.api.Test; |
26 | 25 | import org.mockito.Mockito; |
27 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -82,7 +81,6 @@ void setUp() { |
82 | 81 | "Effective Java Programming", "Healthy Meal Plans", "Best Running Shoes 2024", |
83 | 82 | "Beginner’s Guide to Investing", "How to Brew the Perfect Coffee"); |
84 | 83 |
|
85 | | - |
86 | 84 | @Test |
87 | 85 | void containerStarupTest() { |
88 | 86 | assertEquals(true, postgres.isRunning()); |
@@ -140,7 +138,6 @@ void pageGreaterThanTotalPage() { |
140 | 138 | Integer page = 6; |
141 | 139 | Integer size = 6; |
142 | 140 |
|
143 | | - |
144 | 141 | var response = restTemplate.exchange(bookmarksPaginationURI + "?page={page}&size={size}", |
145 | 142 | HttpMethod.GET, getHttpEntity(restTemplate), PaginatedBookmarkRes.class, page, size); |
146 | 143 |
|
@@ -394,22 +391,21 @@ void deleteBookmarkById() { |
394 | 391 | } |
395 | 392 |
|
396 | 393 | @Test |
397 | | - // flaky test need to investigate why. |
398 | | - @Disabled |
399 | 394 | void attemptToDeleteBookmarkTagThatDoesNotExist() { |
400 | 395 |
|
| 396 | + var header = getHttpEntity(restTemplate); |
401 | 397 | var delResp = restTemplate.exchange(bookmarkURI + "/100" + "/tag?tag={tag}", HttpMethod.DELETE, |
402 | | - getHttpEntity(restTemplate), String.class, "random"); |
| 398 | + header, String.class, "random"); |
403 | 399 |
|
404 | 400 | assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, delResp.getStatusCode()); |
405 | 401 | assertEquals(new BookmarkNotFoundException().getMessage(), delResp.getBody()); |
406 | 402 |
|
407 | 403 | // add the tag. |
408 | 404 | restTemplate.exchange("/api/tags", HttpMethod.POST, |
409 | | - getHttpEntity(restTemplate, List.of("buildings")), TagDTO[].class); |
| 405 | + new HttpEntity<>(List.of("buildings"), header.getHeaders()), TagDTO[].class); |
410 | 406 |
|
411 | | - delResp = restTemplate.exchange(bookmarkURI + "/5" + "/tag?tag={tag}", HttpMethod.DELETE, |
412 | | - getHttpEntity(restTemplate), String.class, "buildings"); |
| 407 | + delResp = restTemplate.exchange(bookmarkURI + "/2" + "/tag?tag={tag}", HttpMethod.DELETE, |
| 408 | + header, String.class, "buildings"); |
413 | 409 |
|
414 | 410 | assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, delResp.getStatusCode()); |
415 | 411 | assertEquals(new TagNotFoundException().getMessage(), delResp.getBody()); |
@@ -521,7 +517,8 @@ void importBookmarksWithUnsupportedContentType() throws IOException { |
521 | 517 | // Create a byte array with application/json content |
522 | 518 | byte[] fileContent = "{\"bookmarks\": []}".getBytes(StandardCharsets.UTF_8); |
523 | 519 |
|
524 | | - // Build the multipart request with a .html extension but unsupported content type |
| 520 | + // Build the multipart request with a .html extension but unsupported content |
| 521 | + // type |
525 | 522 | var bodyBuilder = new MultipartBodyBuilder(); |
526 | 523 | bodyBuilder.part("file", fileContent).filename("invalid_content.html") |
527 | 524 | .contentType(MediaType.APPLICATION_JSON); // Unsupported content type |
@@ -586,7 +583,8 @@ void importBookmarksWithTextPlainContentType() throws IOException { |
586 | 583 | byte[] fileContent = |
587 | 584 | "<html><body>Plain Text Content</body></html>".getBytes(StandardCharsets.UTF_8); |
588 | 585 |
|
589 | | - // Build the multipart request with a .html extension and text/plain content type |
| 586 | + // Build the multipart request with a .html extension and text/plain content |
| 587 | + // type |
590 | 588 | var bodyBuilder = new MultipartBodyBuilder(); |
591 | 589 | bodyBuilder.part("file", fileContent).filename("plainText.html") |
592 | 590 | .contentType(MediaType.TEXT_PLAIN); // Supported content type |
|
0 commit comments