Skip to content

Commit b548a9e

Browse files
committed
api: update
1 parent 444ec29 commit b548a9e

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ RUN sh -c 'touch /api.jar'
66

77
EXPOSE 8080
88

9-
ENTRYPOINT [ "sh", "-c","java -XX:+UseStringDeduplication -jar /api.jar" ]
9+
ENTRYPOINT [ "sh", "-c","java -XX:+UseStringDeduplication -jar /api.jar --spring.datasource.url=jdbc:postgresql://postgres:5432/data-db" ]

api/src/main/java/com/hepsiburada/api/repository/BrowsingHistoryRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public interface BrowsingHistoryRepository extends CrudRepository<BrowsingHistor
1616
@Query(
1717
value = "SELECT product_id FROM browsing_history\n" +
1818
"WHERE user_id = :userId\n" +
19-
"ORDER BY timestamp DESC" +
19+
"ORDER BY timestamp DESC\n" +
2020
"LIMIT 10",
2121
nativeQuery = true
2222
)

api/src/test/java/com/hepsiburada/api/controller/BrowsingHistoryControllerTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,19 @@ public class BrowsingHistoryControllerTest {
3333
@Test
3434
public void givenProductList_whenTenViewedProduct_thenReturnJsonArray() throws Exception {
3535

36+
LinkedHashMap<String, Object> result = new LinkedHashMap<>();
37+
result.put("user-id", 111);
3638
List<Integer> products = List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
39+
result.put("products", products);
40+
result.put("type", "personalized");
3741

38-
Mockito.doReturn(products)
42+
43+
Mockito.doReturn(result)
3944
.when(historyService).getViewedProduct(111);
4045

41-
mvc.perform(get("/api/history/tenproduct")
46+
mvc.perform(get("/api/history/products")
4247
.contentType(MediaType.APPLICATION_JSON)
43-
.param("userid", String.valueOf(111)))
48+
.param("userId", String.valueOf(111)))
4449
.andExpect(status().isOk())
4550
.andExpect(jsonPath("$", isA(LinkedHashMap.class)))
4651
.andExpect(jsonPath("$.type", is("personalized")))

0 commit comments

Comments
 (0)