Skip to content

Commit

Permalink
Fix tests and update message
Browse files Browse the repository at this point in the history
  • Loading branch information
hvs-flick committed Feb 6, 2024
1 parent df72301 commit ed48bdd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class WhatsAppProxy {
private final ObjectMapper objectMapper = new ObjectMapper();

public void sendNotification(WhatsAppNotification eventDataForNotification) {
//String nodeServerUrl = "http://ec2-18-223-205-234.us-east-2.compute.amazonaws.com:3000/";

// Create headers
HttpHeaders headers = new HttpHeaders();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.flickmatch.platform.proxy;

import com.flickmatch.platform.records.WhatsAppNotification;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.http.ResponseEntity;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.client.RestTemplate;

import static org.mockito.ArgumentMatchers.any;
Expand All @@ -21,6 +23,11 @@ class WhatsAppProxyTest {

@InjectMocks WhatsAppProxy whatsAppProxy;

@BeforeEach
void setUp() {
ReflectionTestUtils.setField(whatsAppProxy, "nodeServerUrl", "");
}

@Test
public void test_WhenCallIsSuccessful() {
Mockito.when(restTemplate.postForEntity(anyString(), any(), any())).thenReturn(ResponseEntity.accepted().build());
Expand Down
2 changes: 2 additions & 0 deletions platform/src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ application.local.endpoint=http://localhost:8080/graphql
phonepe.merchant.id=test
phonepe.saltkey=test
phonepe.saltkey.index=1

whatsapp.endpoint=http://localhost:3000/notification
3 changes: 2 additions & 1 deletion whatsapp-js/src/notificationRequestParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ export const createMessage = (jsonData) => {
var message = `${venueName} (${mapLink})
${dateTime}
${format}v${format}
${charges}/- Per Person.
${charges}/- Per Person.
Confirmed Players:`;
for (const [index, value] of jsonData.playerNameList.entries()) {
message = message + '\n' + `${index+1}. ${value}`;
}
message = message + '\n\nPlease pay at play.flickmatch.in to confirm your spot.';
return message;
}
6 changes: 4 additions & 2 deletions whatsapp-js/test/notificationRequestParserTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ const jsonData = '{"startTime":1699715640000,"endTime":1699719240000,"venueName"
const expected = `HotFut GachiBowli (https://goo.gl/maps/1QzakRkJPHxT8GjRA)
20:44 - 21:44 11-10-2023 (Saturday)
5v5
200/- Per Person.
200/- Per Person.
Confirmed Players:
1. Player1
2. Player2
3. sam
4. nooo`;
4. nooo
Please pay at play.flickmatch.in to confirm your spot.`;

function assertEqual(actual, expected, label) {
const areEqual = JSON.stringify(actual) === JSON.stringify(expected);
Expand Down

0 comments on commit ed48bdd

Please sign in to comment.