Skip to content

Commit

Permalink
Enable call to new action service (#229)
Browse files Browse the repository at this point in the history
* Enable call to new action service

* update chart version

* Fixing action event call

Co-authored-by: Amit Sinha <[email protected]>
  • Loading branch information
warrenbailey and Amit Sinha authored Jan 7, 2021
1 parent 367162e commit 940ff23
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
3 changes: 2 additions & 1 deletion _infra/helm/collection-exercise/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ version: 1.2.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 11.0.35
appVersion: 11.0.36


Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import uk.gov.ons.ctp.response.collection.exercise.lib.common.error.CTPException;
import uk.gov.ons.ctp.response.collection.exercise.lib.common.error.CTPException.Fault;
import uk.gov.ons.ctp.response.collection.exercise.lib.common.rest.RestUtility;
import uk.gov.ons.ctp.response.collection.exercise.representation.ProcessEventDTO;

/** HTTP RestClient implementation for calls to the Action service. */
@Component
Expand Down Expand Up @@ -304,10 +303,10 @@ public boolean processEvent(final String tag, final UUID collectionExerciseId)
final UriComponents uriComponents =
restUtility.createUriComponents(appConfig.getActionSvc().getProcessEventPath(), null);

final ProcessEventDTO processEventDTO = new ProcessEventDTO();
processEventDTO.setTag(tag);
processEventDTO.setCollectionExerciseId(collectionExerciseId);
final HttpEntity<ProcessEventDTO> httpEntity = restUtility.createHttpEntity(processEventDTO);
final Event event = new Event();
event.setCollectionExerciseID(collectionExerciseId);
event.setTag(Event.EventTag.valueOf(tag));
final HttpEntity<Event> httpEntity = restUtility.createHttpEntity(event);
final ResponseEntity<String> response =
restTemplate.postForEntity(uriComponents.toUri(), httpEntity, String.class);
return response.getStatusCode().is2xxSuccessful();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package uk.gov.ons.ctp.response.collection.exercise.lib.action.representation;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.UUID;
import javax.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PUBLIC)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Event {
public enum EventTag {
mps,
go_live,
reminder,
reminder2,
reminder3,
nudge_email_0,
nudge_email_1,
nudge_email_2,
nudge_email_3,
nudge_email_4
}

@NotNull private UUID collectionExerciseID;
@NotNull private EventTag tag;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import uk.gov.ons.ctp.response.collection.exercise.client.ActionSvcClient;
import uk.gov.ons.ctp.response.collection.exercise.config.AppConfig;
import uk.gov.ons.ctp.response.collection.exercise.domain.CollectionExercise;
import uk.gov.ons.ctp.response.collection.exercise.domain.Event;
Expand Down Expand Up @@ -120,6 +121,8 @@ public static EventDTO createEventDTOFromEvent(Event event) {

@Autowired private List<ActionRuleRemover> actionRuleRemovers;

@Autowired private ActionSvcClient actionSvcClient;

public Event createEvent(EventDTO eventDto) throws CTPException {
UUID collexId = eventDto.getCollectionExerciseId();
CollectionExercise collex = getCollectionExercise(collexId, Fault.RESOURCE_NOT_FOUND);
Expand Down Expand Up @@ -448,8 +451,8 @@ public void processEvents() {
if (tag.isActionable()) {
log.with("tag", event.getTag()).info("Event is actionable, beginning processing");
// Hard code response until endpoint exists.
// boolean success = actionSvcClient.processEvent(event.getTag(), exercise.getId())
if (true) {
boolean success = actionSvcClient.processEvent(event.getTag(), exercise.getId());
if (success) {
log.info("Event processing succeeded, setting to PROCESSED state");
event.setStatus(EventDTO.Status.PROCESSED);
event.setMessageSent(Timestamp.from(Instant.now()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ public void testProcessEventsTransitionGoLive() {

// Then
verify(eventRepository, atMost(1)).findByStatus(EventDTO.Status.SCHEDULED);
verify(actionSvcClient, never()).processEvent(any(), any());
verify(actionSvcClient, atMost(1)).processEvent(any(), any());
try {
verify(collectionExerciseService, atMost(1))
.transitionCollectionExercise(
Expand Down

0 comments on commit 940ff23

Please sign in to comment.