Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Missing Request fields and Delete properties file #123

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions src/main/java/co/novu/api/events/requests/TriggerEventRequest.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,64 @@
package co.novu.api.events.requests;

import co.novu.api.common.SubscriberRequest;
import co.novu.api.tenants.pojos.Tenant;
import co.novu.common.contracts.IRequest;
import lombok.Data;

import java.util.Map;


@Data
public class TriggerEventRequest implements IRequest {
private String name;
private Object to;// Possible types this field accepts are; SubscriberRequest, List<SubscriberRequest>, Topic or List<Topic>

/**
* Possible types this field accepts are; {@link SubscriberRequest}, list of {@link SubscriberRequest}, {@link Topic} or list of {@link Topic}
*
* <p>For example:
*
* <pre><code>
* SubscriberRequest subscriberRequest = new SubscriberRequest();
* subscriberRequest.setFirstName("fName");
* subscriberRequest.setLastName("lName");
* subscriberRequest.setEmail("[email protected]");
* subscriberRequest.setSubscriberId("subId");
* </code></pre>
*/
private Object to;
private Map<String, Object> payload;
private Map<String, Object> overrides;
private String transactionId;

/**
* Possible types this field accepts are; String or {@link Map}
*
* <p>For example:
*
* <pre><code>
* Map&lt;String, Object&gt; actorMap = new HashMap<>();
* actorMap.put("subscriberId", "sId");
* actorMap.put("email", "[email protected]");
* actorMap.put("firstName", "fName");
* actorMap.put("lastName", "lName");
* actorMap.put("phone", "phoneNo");
* actorMap.put("avatar", "avatarUrl");
* actorMap.put("locale", "locale");
* actorMap.put("data", new Object());
* </code></pre>
*/
private Object actor;

/**
* Possible types this field accepts are; String or {@link Tenant}
*
* <p>For example:
*
* <pre><code>
* Tenant tenant = new Tenant();
* tenant.setIdentifier("identifier");
* tenant.setName("name");
* tenant.setData(new Object());
* </code></pre>
*/
private Object tenant;
}
1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

23 changes: 22 additions & 1 deletion src/test/java/co/novu/api/events/EventsHandlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import co.novu.api.events.responses.CancelEventResponse;
import co.novu.api.events.responses.TriggerEventResponse;
import co.novu.api.events.responses.TriggerEventResponseData;
import co.novu.api.tenants.pojos.Tenant;
import co.novu.common.base.NovuConfig;
import co.novu.common.rest.NovuNetworkException;
import co.novu.common.rest.RestHandler;
Expand All @@ -16,10 +17,11 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.mockito.Mockito;

import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class EventsHandlerTest extends TestCase {

Expand Down Expand Up @@ -47,6 +49,8 @@ public void test_triggerEventToSubscriber() throws IOException, NovuNetworkExcep

triggerEventRequest.setTo(subscriberRequest);
triggerEventRequest.setPayload(Collections.singletonMap("customVariables", "Hello"));
triggerEventRequest.setActor("actor");
triggerEventRequest.setTenant("tenant");

TriggerEventResponse triggerEventResponse = new TriggerEventResponse();
TriggerEventResponseData data = new TriggerEventResponseData();
Expand Down Expand Up @@ -77,6 +81,23 @@ public void test_triggerEventToTopic() throws IOException, NovuNetworkException,
triggerEventRequest.setTo(topic);
triggerEventRequest.setPayload(Collections.singletonMap("customVariables", "Hello"));

Map<String, Object> actorMap = new HashMap<>();
actorMap.put("subscriberId", "sId");
actorMap.put("email", "[email protected]");
actorMap.put("firstName", "fName");
actorMap.put("lastName", "lName");
actorMap.put("phone", "phoneNo");
actorMap.put("avatar", "avatarUrl");
actorMap.put("locale", "locale");
actorMap.put("data", new Object());
triggerEventRequest.setActor(actorMap);

Tenant tenant = new Tenant();
tenant.setIdentifier("identifier");
tenant.setName("name");
tenant.setData(new Object());
triggerEventRequest.setTenant(tenant);

TriggerEventResponse triggerEventResponse = new TriggerEventResponse();
TriggerEventResponseData data = new TriggerEventResponseData();
data.setAcknowledged(true);
Expand Down
1 change: 0 additions & 1 deletion techstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ tools:
category: Application Hosting
sub_category: Platform as a Service
image_url: https://img.stackshare.io/service/3276/xWt1RFo6_400x400.jpg
detection_source: src/main/resources/application.properties
last_updated_by: Mukhtar
last_updated_on: 2023-06-25 20:22:10.000000000 Z
- name: com.squareup.okhttp3:logging-interceptor
Expand Down
Loading