diff --git a/core/pom.xml b/core/pom.xml index 3422d266..45abe375 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -54,6 +54,14 @@ io.github.openfeign.form feign-form + + io.openapitools.jackson.dataformat + jackson-dataformat-hal + + + io.cloudevents + cloudevents-api + junit diff --git a/core/src/main/java/com/adobe/aio/util/JacksonUtil.java b/core/src/main/java/com/adobe/aio/util/JacksonUtil.java index 6e85633f..ab44b7ef 100644 --- a/core/src/main/java/com/adobe/aio/util/JacksonUtil.java +++ b/core/src/main/java/com/adobe/aio/util/JacksonUtil.java @@ -11,11 +11,19 @@ */ package com.adobe.aio.util; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.json.JsonMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.node.TextNode; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import io.cloudevents.json.ZonedDateTimeDeserializer; +import io.cloudevents.json.ZonedDateTimeSerializer; +import io.openapitools.jackson.dataformat.hal.JacksonHALModule; +import java.time.ZonedDateTime; import org.apache.commons.lang3.StringUtils; public class JacksonUtil { @@ -24,9 +32,15 @@ private JacksonUtil() { } public static final ObjectMapper DEFAULT_OBJECT_MAPPER = - new ObjectMapper() - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) - .findAndRegisterModules(); + JsonMapper.builder() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .serializationInclusion(Include.NON_NULL) + .addModule(new SimpleModule() + .addSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer()) + .addDeserializer(ZonedDateTime.class, new ZonedDateTimeDeserializer())) + .addModule(new JacksonHALModule()) + .addModule(new Jdk8Module()) + .build(); public static JsonNode getJsonNode(String jsonPayload) throws JsonProcessingException { if (StringUtils.isEmpty(jsonPayload)) { diff --git a/core/src/main/java/com/adobe/aio/workspace/Workspace.java b/core/src/main/java/com/adobe/aio/workspace/Workspace.java index 8a8b50c6..a37fc69d 100644 --- a/core/src/main/java/com/adobe/aio/workspace/Workspace.java +++ b/core/src/main/java/com/adobe/aio/workspace/Workspace.java @@ -113,6 +113,9 @@ public void validateWorkspaceContext() { if (StringUtils.isEmpty(this.getWorkspaceId())) { throw new IllegalArgumentException("Your `Worskpace` is missing a workspaceId"); } + if (StringUtils.isEmpty(this.getApiKey())) { + throw new IllegalArgumentException("Your `Worskpace` is missing an apiKey"); + } } public String getProjectUrl() { diff --git a/events_journal/src/test/java/com/adobe/aio/event/journal/feign/JournalLinkDecoderTest.java b/events_journal/src/test/java/com/adobe/aio/event/journal/feign/JournalLinkDecoderTest.java index e4464411..b6022249 100644 --- a/events_journal/src/test/java/com/adobe/aio/event/journal/feign/JournalLinkDecoderTest.java +++ b/events_journal/src/test/java/com/adobe/aio/event/journal/feign/JournalLinkDecoderTest.java @@ -15,7 +15,6 @@ import static org.junit.Assert.assertTrue; import com.adobe.aio.event.journal.api.JournalApi; -import com.adobe.aio.event.journal.feign.JournalLinkDecoder; import com.adobe.aio.event.journal.model.JournalEntry; import com.adobe.aio.util.JacksonUtil; import feign.Feign; @@ -31,7 +30,6 @@ public class JournalLinkDecoderTest { private static final String TEST_IMS_ORG_ID = "testImsOrgId"; private static final int RETRY_AFTER_VALUE = 10; - private JournalLinkDecoder journalLinkDecoderUnderTest; @Rule public ExpectedException expectedEx = ExpectedException.none(); diff --git a/events_mgmt/pom.xml b/events_mgmt/pom.xml index 85aa3642..f35efe8f 100644 --- a/events_mgmt/pom.xml +++ b/events_mgmt/pom.xml @@ -48,6 +48,10 @@ aio-lib-java-ims ${project.version} + + io.openapitools.jackson.dataformat + jackson-dataformat-hal + diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/RegistrationService.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/RegistrationService.java index cc26f9c5..526bf589 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/RegistrationService.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/RegistrationService.java @@ -12,9 +12,13 @@ package com.adobe.aio.event.management; import com.adobe.aio.event.management.feign.FeignRegistrationService; +import com.adobe.aio.event.management.model.RegistrationCreateModel; +import com.adobe.aio.event.management.model.RegistrationPaginatedModel; +import com.adobe.aio.event.management.model.RegistrationUpdateModel; import com.adobe.aio.workspace.Workspace; import com.adobe.aio.event.management.model.Registration; -import com.adobe.aio.event.management.model.RegistrationInputModel; +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.List; import java.util.Optional; public interface RegistrationService { @@ -23,9 +27,17 @@ public interface RegistrationService { void delete(String registrationId); - Optional createRegistration( - RegistrationInputModel.Builder registrationInputModelBuilder); + Optional createRegistration(RegistrationCreateModel.Builder registrationCreateModelBuilder); + Optional updateRegistration(String registrationId, RegistrationUpdateModel.Builder registrationUpdateModelBuilder); + + List getRegistrationsForWorkspace(); + + default Optional getAllRegistrationsForOrg() throws JsonProcessingException { + return getAllRegistrationsForOrg(0L, 10L); + } + + Optional getAllRegistrationsForOrg(long page, long size) throws JsonProcessingException; static Builder builder() { return new Builder(); diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/api/RegistrationApi.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/api/RegistrationApi.java index 5171216b..148e162f 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/api/RegistrationApi.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/api/RegistrationApi.java @@ -12,76 +12,117 @@ package com.adobe.aio.event.management.api; import com.adobe.aio.event.management.model.Registration; -import com.adobe.aio.event.management.model.RegistrationInputModel; +import com.adobe.aio.event.management.model.RegistrationCollection; +import com.adobe.aio.event.management.model.RegistrationCreateModel; +import com.adobe.aio.event.management.model.RegistrationPaginatedModel; +import com.adobe.aio.event.management.model.RegistrationUpdateModel; import feign.Headers; import feign.Param; import feign.RequestLine; import java.util.Optional; -@Headers("Accept: application/json") +@Headers({"Accept: application/hal+json"}) public interface RegistrationApi { - /** - * Creates a Webhook or a Journal registration - * - * @param imsOrgId your Ims Org Id - * @param consumerOrgId Your consumer organization Id - * @param credentialId The integration Id associated with your project/workspace - * @param body your Registration Input - * @return Registration - */ - @RequestLine("POST /events/organizations/{consumerOrgId}/integrations/{credentialId}/registrations") - @Headers({ - "Content-Type: application/json", - "x-ims-org-id: {imsOrgId}", - }) - Optional post( - @Param("imsOrgId") String imsOrgId, + /** + * Creates a Webhook or a Journal registration + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param body your Registration Input + * @return Registration + */ + @RequestLine("POST /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations") + @Headers({"Content-Type: application/json"}) + Optional post( @Param("consumerOrgId") String consumerOrgId, - @Param("credentialId") String credentialId, - RegistrationInputModel body - ); + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, + RegistrationCreateModel body + ); - /** - * GET a registration - * - * @param imsOrgId your Ims Org Id - * @param consumerOrgId Your consumer organization Id - * @param credentialId The integration Id associated with your project/workspace - * @param registrationId The Registration Id - * @return Registration - */ - @RequestLine("GET /events/organizations/{consumerOrgId}/integrations/{credentialId}/registrations/{registrationId}") - @Headers({ - "Content-Type: application/json", - "x-ims-org-id: {imsOrgId}", - }) - Optional get( - @Param("imsOrgId") String imsOrgId, + /** + * Updates a Webhook or a Journal registration + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + * @param body your Registration Input + * @return Registration + */ + @RequestLine("PUT /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}") + @Headers({"Content-Type: application/json"}) + Optional put( @Param("consumerOrgId") String consumerOrgId, - @Param("credentialId") String credentialId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, + @Param("registrationId") String registrationId, + RegistrationUpdateModel body + ); + + /** + * GET a registration + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + * @return Registration + */ + @RequestLine("GET /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}") + @Headers({"Content-Type: application/json"}) + Optional get( + @Param("consumerOrgId") String consumerOrgId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, @Param("registrationId") String registrationId - ); + ); + + /** + * GET all registrations for a project/workspace + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @return Registration + */ + @RequestLine("GET /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations") + @Headers({"Content-Type: application/json"}) + Optional getAllForWorkspace( + @Param("consumerOrgId") String consumerOrgId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId); + + /** + * GET all registrations for an org + * + * @param consumerOrgId Your consumer organization Id + * @return Registration + */ + @RequestLine("GET /events/{consumerOrgId}/registrations?page={page}&size={size}") + @Headers({"Content-Type: application/json"}) + Optional getAllForOrg( + @Param("consumerOrgId") String consumerOrgId, + @Param("page") Long page, + @Param("size") Long size); - /** - * DELETE a registration - * - * @param imsOrgId your Ims Org Id - * @param consumerOrgId Your consumer organization Id - * @param credentialId The integration Id associated with your project/workspace - * @param registrationId The Registration Id - */ - @RequestLine("DELETE /events/organizations/{consumerOrgId}/integrations/{credentialId}/registrations/{registrationId}") - @Headers({ - "Content-Type: application/json", - "x-ims-org-id: {imsOrgId}", - }) - void delete( - @Param("imsOrgId") String imsOrgId, + /** + * DELETE a registration + * + * @param consumerOrgId Your consumer organization Id + * @param projectId The Id associated with your project + * @param workspaceId The Id associated with your workspace + * @param registrationId The Registration Id + */ + @RequestLine("DELETE /events/{consumerOrgId}/{projectId}/{workspaceId}/registrations/{registrationId}") + void delete( @Param("consumerOrgId") String consumerOrgId, - @Param("credentialId") String credentialId, + @Param("projectId") String projectId, + @Param("workspaceId") String workspaceId, @Param("registrationId") String registrationId - ); + ); } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/feign/FeignRegistrationService.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/feign/FeignRegistrationService.java index 87ac1cc0..389a5da1 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/feign/FeignRegistrationService.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/feign/FeignRegistrationService.java @@ -14,14 +14,19 @@ import static com.adobe.aio.util.Constants.API_MANAGEMENT_URL; import com.adobe.aio.event.management.RegistrationService; -import com.adobe.aio.feign.AIOHeaderInterceptor; -import com.adobe.aio.ims.feign.JWTAuthInterceptor; -import com.adobe.aio.workspace.Workspace; import com.adobe.aio.event.management.api.RegistrationApi; import com.adobe.aio.event.management.model.Registration; -import com.adobe.aio.event.management.model.RegistrationInputModel; +import com.adobe.aio.event.management.model.RegistrationCreateModel; +import com.adobe.aio.event.management.model.RegistrationPaginatedModel; +import com.adobe.aio.event.management.model.RegistrationUpdateModel; +import com.adobe.aio.feign.AIOHeaderInterceptor; +import com.adobe.aio.ims.feign.JWTAuthInterceptor; import com.adobe.aio.util.feign.FeignUtil; +import com.adobe.aio.workspace.Workspace; +import com.fasterxml.jackson.core.JsonProcessingException; import feign.RequestInterceptor; +import java.util.ArrayList; +import java.util.List; import java.util.Optional; import org.apache.commons.lang3.StringUtils; @@ -36,18 +41,6 @@ public FeignRegistrationService(final Workspace workspace, if (workspace == null) { throw new IllegalArgumentException("RegistrationService is missing a workspace context"); } - if (StringUtils.isEmpty(workspace.getImsOrgId())) { - throw new IllegalArgumentException("Workspace is missing an imsOrgId context"); - } - if (StringUtils.isEmpty(workspace.getConsumerOrgId())) { - throw new IllegalArgumentException("Workspace is missing a consumerOrgId context"); - } - if (StringUtils.isEmpty(workspace.getCredentialId())) { - throw new IllegalArgumentException("Workspace is missing a credentialId context"); - } - if (StringUtils.isEmpty(workspace.getApiKey())) { - throw new IllegalArgumentException("Workspace is missing an apiKey context"); - } workspace.validateWorkspaceContext(); RequestInterceptor authInterceptor = JWTAuthInterceptor.builder().workspace(workspace).build(); this.registrationApi = FeignUtil.getDefaultBuilder() @@ -62,8 +55,8 @@ public Optional findById(String registrationId) { if (StringUtils.isEmpty(registrationId)) { throw new IllegalArgumentException("registrationId cannot be null or empty"); } - return registrationApi.get(workspace.getImsOrgId(), workspace.getConsumerOrgId(), - workspace.getCredentialId(), registrationId); + return registrationApi.get(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId); } @Override @@ -71,17 +64,36 @@ public void delete(String registrationId) { if (StringUtils.isEmpty(registrationId)) { throw new IllegalArgumentException("registrationId cannot be null or empty"); } - registrationApi.delete(workspace.getImsOrgId(), workspace.getConsumerOrgId(), - workspace.getCredentialId(), registrationId); + registrationApi.delete(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId); } @Override public Optional createRegistration( - RegistrationInputModel.Builder registrationInputModelBuilder) { - RegistrationInputModel inputModel = registrationInputModelBuilder + RegistrationCreateModel.Builder registrationCreateModelBuilder) { + var inputModel = registrationCreateModelBuilder .clientId(workspace.getApiKey()).build(); - return registrationApi.post(workspace.getImsOrgId(), workspace.getConsumerOrgId(), - workspace.getCredentialId(), inputModel); + return registrationApi.post(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), inputModel); + } + + @Override + public Optional updateRegistration(String registrationId, + RegistrationUpdateModel.Builder registrationUpdateModelBuilder) { + var inputModel = registrationUpdateModelBuilder.build(); + return registrationApi.put(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId(), registrationId, inputModel); } + @Override public List getRegistrationsForWorkspace() { + var registrationCollection = registrationApi.getAllForWorkspace(workspace.getConsumerOrgId(), workspace.getProjectId(), + workspace.getWorkspaceId()); + return registrationCollection.map(collection -> new ArrayList<>(collection.getRegistrationHalModels())) + .orElseGet(ArrayList::new); + } + + @Override + public Optional getAllRegistrationsForOrg(final long page, final long size) throws JsonProcessingException { + return registrationApi.getAllForOrg(workspace.getConsumerOrgId(), page, size); + } } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/DeliveryType.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/DeliveryType.java index 305e328c..8f8c7074 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/DeliveryType.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/DeliveryType.java @@ -11,6 +11,50 @@ */ package com.adobe.aio.event.management.model; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public enum DeliveryType { - WEBHOOK, JOURNAL, WEBHOOK_BATCH + WEBHOOK("webhook", true), JOURNAL("journal", false), + WEBHOOK_BATCH("webhook_batch", true); + + private final boolean isWebhookDelivery; + private final String friendlyName; + + private static final Logger logger = LoggerFactory.getLogger(DeliveryType.class); + + private static final Map DELIVERY_TYPE_FRIENDLY_NAME_MAP = new HashMap<>(); + + static { + Stream.of(DeliveryType.values()) + .filter(deliveryType -> StringUtils.isNotBlank(deliveryType.getFriendlyName())) + .forEach(deliveryType -> DELIVERY_TYPE_FRIENDLY_NAME_MAP.put(deliveryType.getFriendlyName().toLowerCase(), + deliveryType)); + } + + public static DeliveryType fromFriendlyName(String friendlyName) { + if (!DELIVERY_TYPE_FRIENDLY_NAME_MAP.containsKey(friendlyName.toLowerCase())) { + logger.error("`{}` is not a delivery type known to Adobe I/O Events", friendlyName); + throw new IllegalArgumentException("Invalid delivery type code: " + friendlyName); + } else { + return DELIVERY_TYPE_FRIENDLY_NAME_MAP.get(friendlyName.toLowerCase()); + } + } + + public boolean isWebhookDelivery() { + return isWebhookDelivery; + } + + public String getFriendlyName() { + return friendlyName; + } + + DeliveryType(String friendlyName, boolean isWebhookDelivery) { + this.isWebhookDelivery = isWebhookDelivery; + this.friendlyName = friendlyName; + } } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventsOfInterest.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventsOfInterest.java index a9adfba2..42156504 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventsOfInterest.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventsOfInterest.java @@ -11,36 +11,90 @@ */ package com.adobe.aio.event.management.model; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Objects; -import org.apache.commons.lang3.StringUtils; +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) public class EventsOfInterest { @JsonProperty("event_code") - String eventCode; + protected final String eventCode; @JsonProperty("provider_id") - String providerId; + protected final String providerId; - private EventsOfInterest() { - } + @JsonProperty("event_label") + protected final String eventLabel; - private EventsOfInterest(String providerId, String eventCode) { - if (StringUtils.isBlank(providerId) || StringUtils.isBlank(eventCode)){ - throw new IllegalArgumentException("Invalid EventsOfInterest, neither providerId, nor eventCode can be empty/blank"); - } - this.providerId = providerId; + @JsonProperty("event_description") + protected final String eventDescription; + + @JsonProperty("provider_label") + protected final String providerLabel; + + @JsonProperty("provider_description") + protected final String providerDescription; + + @JsonProperty("provider_docs_url") + protected final String providerDocsUrl; + + @JsonProperty("event_delivery_format") + protected final String eventDeliveryFormat; + + @JsonCreator + public EventsOfInterest(@JsonProperty("event_code") String eventCode, + @JsonProperty("provider_id") String providerId, + @JsonProperty("event_label") String eventLabel, + @JsonProperty("event_description") String eventDescription, + @JsonProperty("provider_label") String providerLabel, + @JsonProperty("provider_description") String providerDescription, + @JsonProperty("provider_docs_url") String providerDocsUrl, + @JsonProperty("event_delivery_format") String eventDeliveryFormat) { this.eventCode = eventCode; + this.providerId = providerId; + this.eventLabel = eventLabel; + this.eventDescription = eventDescription; + this.providerLabel = providerLabel; + this.providerDescription = providerDescription; + this.providerDocsUrl = providerDocsUrl; + this.eventDeliveryFormat = eventDeliveryFormat; + } + + public String getEventCode() { + return eventCode; } public String getProviderId() { return providerId; } - public String getEventCode() { - return eventCode; + public String getEventDeliveryFormat() { + return eventDeliveryFormat; + } + + public String getEventLabel() { + return eventLabel; + } + + public String getEventDescription() { + return eventDescription; + } + + public String getProviderLabel() { + return providerLabel; + } + + public String getProviderDescription() { + return providerDescription; + } + + public String getProviderDocsUrl() { + return providerDocsUrl; } @Override @@ -48,49 +102,37 @@ public boolean equals(Object o) { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (!(o instanceof EventsOfInterest)) { return false; } EventsOfInterest that = (EventsOfInterest) o; return Objects.equals(eventCode, that.eventCode) && - Objects.equals(providerId, that.providerId); + Objects.equals(providerId, that.providerId) && + Objects.equals(eventLabel, that.eventLabel) && + Objects.equals(eventDescription, that.eventDescription) && + Objects.equals(providerLabel, that.providerLabel) && + Objects.equals(providerDescription, that.providerDescription) && + Objects.equals(providerDocsUrl, that.providerDocsUrl) && + Objects.equals(eventDeliveryFormat, that.eventDeliveryFormat); } @Override public int hashCode() { - return Objects.hash(eventCode, providerId); + return Objects.hash(eventCode, providerId, eventLabel, eventDescription, providerLabel, providerDescription, providerDocsUrl, + eventDeliveryFormat); } @Override public String toString() { return "EventsOfInterest{" + - "eventCode='" + eventCode + '\'' + - ", providerId='" + providerId + '\'' + - '}'; - } - - @JsonIgnore - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private String providerId; - private String eventCode; - - public Builder providerId(String providerId) { - this.providerId = providerId; - return this; - } - - public Builder eventCode(String eventCode) { - this.eventCode = eventCode; - return this; - } - - public EventsOfInterest build() { - return new EventsOfInterest(providerId, eventCode); - } + "eventCode='" + eventCode + '\'' + + ", providerId='" + providerId + '\'' + + ", eventLabel='" + eventLabel + '\'' + + ", eventDescription='" + eventDescription + '\'' + + ", providerLabel='" + providerLabel + '\'' + + ", providerDescription='" + providerDescription + '\'' + + ", providerDocsUrl='" + providerDocsUrl + '\'' + + ", eventDeliveryFormat='" + eventDeliveryFormat + '\'' + + '}'; } } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventsOfInterestInputModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventsOfInterestInputModel.java new file mode 100644 index 00000000..55d3e9ea --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/EventsOfInterestInputModel.java @@ -0,0 +1,96 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import org.apache.commons.lang3.StringUtils; + +public class EventsOfInterestInputModel { + + @JsonProperty("event_code") + String eventCode; + + @JsonProperty("provider_id") + String providerId; + + private EventsOfInterestInputModel() { + } + + private EventsOfInterestInputModel(String providerId, String eventCode) { + if (StringUtils.isBlank(providerId) || StringUtils.isBlank(eventCode)){ + throw new IllegalArgumentException("Invalid EventsOfInterestInputModel, neither providerId, nor eventCode can be empty/blank"); + } + this.providerId = providerId; + this.eventCode = eventCode; + } + + public String getProviderId() { + return providerId; + } + + public String getEventCode() { + return eventCode; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventsOfInterestInputModel that = (EventsOfInterestInputModel) o; + return Objects.equals(eventCode, that.eventCode) && + Objects.equals(providerId, that.providerId); + } + + @Override + public int hashCode() { + return Objects.hash(eventCode, providerId); + } + + @Override + public String toString() { + return "EventsOfInterestInputModel{" + + "eventCode='" + eventCode + '\'' + + ", providerId='" + providerId + '\'' + + '}'; + } + + @JsonIgnore + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private String providerId; + private String eventCode; + + public Builder providerId(String providerId) { + this.providerId = providerId; + return this; + } + + public Builder eventCode(String eventCode) { + this.eventCode = eventCode; + return this; + } + + public EventsOfInterestInputModel build() { + return new EventsOfInterestInputModel(providerId, eventCode); + } + } +} diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java index 184f03a9..f3ce9dc1 100644 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/Registration.java @@ -11,65 +11,131 @@ */ package com.adobe.aio.event.management.model; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.HashSet; +import io.openapitools.jackson.dataformat.hal.HALLink; +import io.openapitools.jackson.dataformat.hal.annotation.Link; +import io.openapitools.jackson.dataformat.hal.annotation.Resource; import java.util.Objects; import java.util.Set; +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@Resource public class Registration { - public enum Status { - ACCEPTED, - DELETED, - VERIFICATION_FAILED, - HOOK_UNREACHABLE, - UNSTABLE, - VERIFIED - } + @Link + private HALLink self; - public enum IntegrationStatus { - ENABLED, DISABLED - } + @Link("rel:events") + private HALLink eventsUrl; - @JsonProperty("client_id") - protected String clientId; + @Link("rel:trace") + private HALLink traceUrl; + + private final Long id; - protected String name; + private final String name; - protected String description; + private final String description; + + @JsonProperty("client_id") + private final String clientId; + + @JsonProperty("registration_id") + private final String registrationId; @JsonProperty("delivery_type") - protected DeliveryType deliveryType; + private final String deliveryType; - @JsonProperty("events_of_interest") - protected Set eventsOfInterests = new HashSet<>(); + @JsonProperty("webhook_status") + private final String webhookStatus; + + @JsonProperty(value = "created_date") + private final String createdDate; + + @JsonProperty(value = "updated_date") + private final String updatedDate; + + @JsonProperty("consumer_id") + private final String consumerId; + + @JsonProperty("project_id") + private final String projectId; + + @JsonProperty("workspace_id") + private final String workspaceId; @JsonProperty("webhook_url") - protected String webhookUrl; + private final String webhookUrl; - @JsonProperty("registration_id") - private String registrationId; + @JsonProperty("runtime_action") + private final String runtimeAction; - @JsonProperty("status") - private Status status; + @JsonProperty("enabled") + private final boolean enabled; - @JsonProperty("integration_status") - private IntegrationStatus integrationStatus; + @JsonProperty("events_of_interest") + private final Set eventsOfInterests; + + @JsonCreator + public Registration( + @JsonProperty("id") Long id, + @JsonProperty("name") String name, + @JsonProperty("description") String description, + @JsonProperty("client_id") String clientId, + @JsonProperty("registration_id") String registrationId, + @JsonProperty("delivery_type") String deliveryType, + @JsonProperty("webhook_status") String webhookStatus, + @JsonProperty(value = "created_date") String createdDate, + @JsonProperty(value = "updated_date") String updatedDate, + @JsonProperty("consumer_id") String consumerId, + @JsonProperty("project_id") String projectId, + @JsonProperty("workspace_id") String workspaceId, + @JsonProperty("webhook_url") String webhookUrl, + @JsonProperty("runtime_action") String runtimeAction, + @JsonProperty("enabled") boolean enabled, + @JsonProperty("events_of_interest") Set eventsOfInterests) { + this.id = id; + this.name = name; + this.description = description; + this.clientId = clientId; + this.registrationId = registrationId; + this.deliveryType = deliveryType; + this.webhookStatus = webhookStatus; + this.createdDate = createdDate; + this.updatedDate = updatedDate; + this.consumerId = consumerId; + this.projectId = projectId; + this.workspaceId = workspaceId; + this.webhookUrl = webhookUrl; + this.runtimeAction = runtimeAction; + this.enabled = enabled; + this.eventsOfInterests = eventsOfInterests; + this.self = self; + this.traceUrl = traceUrl; + this.eventsUrl = eventsUrl; + } - @JsonProperty(value = "events_url") - private String journalUrl; - @JsonProperty(value = "trace_url") - private String traceUrl; - @JsonProperty(value = "created_date") - private String createdDate; + public HALLink getSelf() { + return self; + } - @JsonProperty(value = "updated_date") - private String updatedDate; + public HALLink getEventsUrl() { + return eventsUrl; + } - public String getClientId() { - return clientId; + public HALLink getTraceUrl() { + return traceUrl; + } + + public Long getId() { + return id; } public String getName() { @@ -80,94 +146,113 @@ public String getDescription() { return description; } - public DeliveryType getDeliveryType() { + public String getClientId() { + return clientId; + } + + public String getRegistrationId() { + return registrationId; + } + + public String getDeliveryType() { return deliveryType; } - public Set getEventsOfInterests() { - return eventsOfInterests; + public String getWebhookStatus() { + return webhookStatus; } - public String getWebhookUrl() { - return webhookUrl; + public String getCreatedDate() { + return createdDate; } - public String getRegistrationId() { - return this.registrationId; + public String getUpdatedDate() { + return updatedDate; } - public Status getStatus() { - return this.status; + public String getConsumerId() { + return consumerId; } - public IntegrationStatus getIntegrationStatus() { - return integrationStatus; + public String getProjectId() { + return projectId; } - public String getJournalUrl() { - return journalUrl; + public String getWorkspaceId() { + return workspaceId; } - public String getTraceUrl() { - return traceUrl; + public String getWebhookUrl() { + return webhookUrl; } - public String getCreatedDate() { - return createdDate; + public String getRuntimeAction() { + return runtimeAction; } - public String getUpdatedDate() { - return updatedDate; + public boolean isEnabled() { + return enabled; + } + + public Set getEventsOfInterests() { + return eventsOfInterests; } - @Override - public boolean equals(Object o) { + @Override public boolean equals(Object o) { if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { + if (!(o instanceof Registration)) { return false; } Registration that = (Registration) o; - return Objects.equals(registrationId, that.registrationId) && - Objects.equals(clientId, that.clientId) && - Objects.equals(name, that.name) && - Objects.equals(description, that.description) && - Objects.equals(eventsOfInterests, that.eventsOfInterests) && - Objects.equals(webhookUrl, that.webhookUrl) && - status == that.status && - integrationStatus == that.integrationStatus && - deliveryType == that.deliveryType && - Objects.equals(journalUrl, that.journalUrl) && - Objects.equals(traceUrl, that.traceUrl) && - Objects.equals(createdDate, that.createdDate) && - Objects.equals(updatedDate, that.updatedDate); - } - - @Override - public int hashCode() { - return Objects - .hash(registrationId, clientId, name, description, eventsOfInterests, - webhookUrl, status, integrationStatus, deliveryType, journalUrl, traceUrl, - createdDate, updatedDate); - } - - @Override - public String toString() { + return enabled == that.enabled && + Objects.equals(self, that.self) && + Objects.equals(eventsUrl, that.eventsUrl) && + Objects.equals(traceUrl, that.traceUrl) && + Objects.equals(id, that.id) && + Objects.equals(name, that.name) && + Objects.equals(description, that.description) && + Objects.equals(clientId, that.clientId) && + Objects.equals(registrationId, that.registrationId) && + Objects.equals(deliveryType, that.deliveryType) && + Objects.equals(webhookStatus, that.webhookStatus) && + Objects.equals(createdDate, that.createdDate) && + Objects.equals(updatedDate, that.updatedDate) && + Objects.equals(consumerId, that.consumerId) && + Objects.equals(projectId, that.projectId) && + Objects.equals(workspaceId, that.workspaceId) && + Objects.equals(webhookUrl, that.webhookUrl) && + Objects.equals(runtimeAction, that.runtimeAction) && + Objects.equals(eventsOfInterests, that.eventsOfInterests); + } + + @Override public int hashCode() { + return Objects.hash(self, eventsUrl, traceUrl, id, name, description, clientId, registrationId, deliveryType, webhookStatus, + createdDate, updatedDate, consumerId, projectId, workspaceId, webhookUrl, runtimeAction, enabled, eventsOfInterests); + } + + @Override public String toString() { return "Registration{" + - " name='" + name + '\'' + - ", registrationId='" + registrationId + '\'' + - ", description='" + description + '\'' + - ", eventsOfInterests=" + eventsOfInterests + - ", deliveryType=" + deliveryType + - ", clientId='" + clientId + '\'' + - ", status=" + status + - ", integrationStatus=" + integrationStatus + - ", webhookUrl='" + webhookUrl + '\'' + - ", journalUrl='" + journalUrl + '\'' + - ", traceUrl='" + traceUrl + '\'' + - ", createdDate='" + createdDate + '\'' + - ", updatedDate='" + updatedDate + '\'' + - '}'; + "self=" + self + + ", eventsUrl=" + eventsUrl + + ", traceUrl=" + traceUrl + + ", id=" + id + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", clientId='" + clientId + '\'' + + ", registrationId='" + registrationId + '\'' + + ", deliveryType='" + deliveryType + '\'' + + ", webhookStatus='" + webhookStatus + '\'' + + ", createdDate='" + createdDate + '\'' + + ", updatedDate='" + updatedDate + '\'' + + ", consumerId='" + consumerId + '\'' + + ", projectId='" + projectId + '\'' + + ", workspaceId='" + workspaceId + '\'' + + ", webhookUrl='" + webhookUrl + '\'' + + ", runtimeAction='" + runtimeAction + '\'' + + ", enabled=" + enabled + + ", eventsOfInterests=" + eventsOfInterests + + '}'; } } diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCollection.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCollection.java new file mode 100644 index 00000000..8ffff423 --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCollection.java @@ -0,0 +1,77 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import io.openapitools.jackson.dataformat.hal.HALLink; +import io.openapitools.jackson.dataformat.hal.annotation.EmbeddedResource; +import io.openapitools.jackson.dataformat.hal.annotation.Link; +import io.openapitools.jackson.dataformat.hal.annotation.Resource; +import java.util.Collection; +import java.util.Collections; +import java.util.Objects; + +@Resource +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class RegistrationCollection { + + @Link + private HALLink self; + + @EmbeddedResource("registrations") + private Collection registrationHalModels; + + public HALLink getSelf() { + return self; + } + + public void setSelf(HALLink self) { + this.self = self; + } + + public Collection getRegistrationHalModels() { + return Collections.unmodifiableCollection(registrationHalModels); + } + + public void setRegistrationHalModels(Collection registrationHalModels) { + this.registrationHalModels = registrationHalModels; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof RegistrationCollection)) { + return false; + } + RegistrationCollection that = (RegistrationCollection) o; + return Objects.equals(self, that.self) && + Objects.equals(registrationHalModels, that.registrationHalModels); + } + + @Override + public int hashCode() { + return Objects.hash(self, registrationHalModels); + } + + @Override + public String toString() { + return "RegistrationCollectionHalModel{" + + "self=" + self + + ", RegistrationHalModels=" + registrationHalModels + + '}'; + } +} diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCreateModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCreateModel.java new file mode 100644 index 00000000..960c813d --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationCreateModel.java @@ -0,0 +1,97 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import java.util.Set; +import org.apache.commons.lang3.StringUtils; + +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class RegistrationCreateModel extends RegistrationUpdateModel { + + @JsonProperty("client_id") + private final String clientId; + + public RegistrationCreateModel(final String clientId, final String name, final String description, + final String deliveryType, final Set eventsOfInterestInputModels, + final String webhookUrl, final boolean enabled) { + super(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, enabled); + if (StringUtils.isBlank(clientId)) { + throw new IllegalArgumentException( + "Registration is missing a clientId"); + } + this.clientId = clientId; + } + + public String getClientId() { + return clientId; + } + + @Override public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof RegistrationCreateModel)) { + return false; + } + if (!super.equals(o)) { + return false; + } + RegistrationCreateModel that = (RegistrationCreateModel) o; + return Objects.equals(clientId, that.clientId); + } + + @Override + public int hashCode() { + return Objects.hash(clientId, name, description, deliveryType, eventsOfInterestInputModels, webhookUrl, enabled); + } + + @Override + public String toString() { + return "RegistrationInputModel{" + + "clientId='" + clientId + '\'' + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", deliveryType=" + deliveryType + + ", eventsOfInterestInputModels=" + eventsOfInterestInputModels + + ", webhookUrl='" + webhookUrl + '\'' + + ", enabled='" + enabled + '\'' + + '}'; + } + + @JsonIgnore + public static Builder builder() { + return new Builder(); + } + + + public static class Builder extends RegistrationUpdateModel.Builder { + protected String clientId; + + public Builder clientId(String clientId) { + this.clientId = clientId; + return this; + } + + @Override + public RegistrationCreateModel build() { + return new RegistrationCreateModel(clientId, name, description, deliveryType, eventsOfInterestInputModels, + webhookUrl, enabled); + } + } +} diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationInputModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationInputModel.java deleted file mode 100644 index fb99f1fa..00000000 --- a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationInputModel.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2017 Adobe. All rights reserved. - * This file is licensed to you under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. You may obtain a copy - * of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS - * OF ANY KIND, either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package com.adobe.aio.event.management.model; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; -import org.apache.commons.lang3.StringUtils; - -public class RegistrationInputModel { - - @JsonProperty("client_id") - private final String clientId; - - private final String name; - - private final String description; - - @JsonProperty("delivery_type") - private final DeliveryType deliveryType; - - @JsonProperty("events_of_interest") - private final Set eventsOfInterests; - - @JsonProperty("webhook_url") - private final String webhookUrl; - - private RegistrationInputModel(final String clientId, final String name, final String description, - final DeliveryType deliveryType, final Set eventsOfInterests, - final String webhookUrl) { - if (StringUtils.isBlank(name)){ - throw new IllegalArgumentException( - "RegistrationInputModel is missing a name"); - } - if (StringUtils.isBlank(clientId)){ - throw new IllegalArgumentException( - "RegistrationInputModel is missing a clientId"); - } - if (deliveryType == null && StringUtils.isEmpty(webhookUrl)) { - this.deliveryType = DeliveryType.JOURNAL; - } else if (deliveryType == null && !StringUtils.isEmpty(webhookUrl)) { - this.deliveryType = DeliveryType.WEBHOOK; - } else if (deliveryType != DeliveryType.JOURNAL && StringUtils.isEmpty(webhookUrl)) { - throw new IllegalArgumentException( - "RegistrationInputModel is a webhook registration, but missing a webhook url"); - } else { - this.deliveryType = deliveryType; - } - this.webhookUrl = webhookUrl;//Todo validate url, must be https - this.clientId = clientId; - this.name = name; - this.description = description; - this.eventsOfInterests = eventsOfInterests; - } - - public String getClientId() { - return clientId; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public DeliveryType getDeliveryType() { - return deliveryType; - } - - public Set getEventsOfInterests() { - return eventsOfInterests; - } - - public String getWebhookUrl() { - return webhookUrl; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RegistrationInputModel that = (RegistrationInputModel) o; - return Objects.equals(clientId, that.clientId) && - Objects.equals(name, that.name) && - Objects.equals(description, that.description) && - deliveryType == that.deliveryType && - Objects.equals(eventsOfInterests, that.eventsOfInterests) && - Objects.equals(webhookUrl, that.webhookUrl); - } - - @Override - public int hashCode() { - return Objects.hash(clientId, name, description, deliveryType, eventsOfInterests, webhookUrl); - } - - @Override - public String toString() { - return "RegistrationInputModel{" + - "clientId='" + clientId + '\'' + - ", name='" + name + '\'' + - ", description='" + description + '\'' + - ", deliveryType=" + deliveryType + - ", eventsOfInterests=" + eventsOfInterests + - ", webhookUrl='" + webhookUrl + '\'' + - '}'; - } - - @JsonIgnore - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private String clientId; - private String name; - private String description; - private DeliveryType deliveryType; - private Set eventsOfInterests = new HashSet<>(); - private String webhookUrl; - - public Builder() { - } - - public Builder clientId(String clientId) { - this.clientId = clientId; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder description(String description) { - this.description = description; - return this; - } - - public Builder deliveryType(DeliveryType deliveryType) { - this.deliveryType = deliveryType; - return this; - } - - public Builder addEventsOfInterests( - EventsOfInterest eventsOfInterest) { - this.eventsOfInterests.add(eventsOfInterest); - return this; - } - - public Builder addEventsOfInterests( - Set eventsOfInterest) { - this.eventsOfInterests.addAll(eventsOfInterest); - return this; - } - - public Builder webhookUrl(String webhookUrl) { - this.webhookUrl = webhookUrl; - return this; - } - - public RegistrationInputModel build() { - return new RegistrationInputModel(clientId, name, description, deliveryType, - eventsOfInterests, - webhookUrl); - } - } -} diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationPaginatedModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationPaginatedModel.java new file mode 100644 index 00000000..2f5d28fa --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationPaginatedModel.java @@ -0,0 +1,176 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.openapitools.jackson.dataformat.hal.HALLink; +import io.openapitools.jackson.dataformat.hal.annotation.Link; +import io.openapitools.jackson.dataformat.hal.annotation.Resource; +import java.util.Objects; + +@Resource +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class RegistrationPaginatedModel extends RegistrationCollection{ + + @Link + private HALLink next; + + @Link + private HALLink prev; + + @Link + private HALLink first; + + @Link + private HALLink last; + + private PageMetadata page; + + public HALLink getNext() { + return next; + } + + public HALLink getPrev() { + return prev; + } + + public void setPrev(HALLink prev) { + this.prev = prev; + } + + public HALLink getFirst() { + return first; + } + + public HALLink getLast() { + return last; + } + + public PageMetadata getPage() { + return page; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof RegistrationPaginatedModel)) { + return false; + } + if (!super.equals(o)) { + return false; + } + RegistrationPaginatedModel that = (RegistrationPaginatedModel) o; + return Objects.equals(next, that.next) && + Objects.equals(prev, that.prev) && + Objects.equals(first, that.first) && + Objects.equals(last, that.last) && + Objects.equals(page, that.page); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), next, prev, first, last, page); + } + + @Override + public String toString() { + return "RegistrationPaginatedHalModel{" + + "next=" + next + + ", prev=" + prev + + ", first=" + first + + ", last=" + last + + ", page=" + page + + ", self=" + getSelf() + + ", Registrations=" + getRegistrationHalModels() + + '}'; + } + + public static class PageMetadata { + private final int size; //page size + private final int number;// page number + private final int numberOfElements; // number of elements in page fetched + private final long totalElements; // total number of elements + private final int totalPages; // total number of pages + + @JsonCreator + public PageMetadata(@JsonProperty("size") int size, + @JsonProperty("number") int number, + @JsonProperty("numberOfElements") int numberOfElements, + @JsonProperty("totalElements") long totalElements, + @JsonProperty("totalPages") int totalPages) { + this.size = size; + this.number = number; + this.numberOfElements = numberOfElements; + this.totalElements = totalElements; + this.totalPages = totalPages; + } + + public int getSize() { + return size; + } + + public int getNumber() { + return number; + } + + public int getNumberOfElements() { + return numberOfElements; + } + + public long getTotalElements() { + return totalElements; + } + + public int getTotalPages() { + return totalPages; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PageMetadata that = (PageMetadata) o; + return size == that.size && + number == that.number && + numberOfElements == that.numberOfElements && + totalElements == that.totalElements && + totalPages == that.totalPages; + } + + @Override + public int hashCode() { + return Objects.hash(size, number, numberOfElements, totalElements, totalPages); + } + + @Override + public String toString() { + return "PageMetadata{" + + "size=" + size + + ", number=" + number + + ", numberOfElements=" + numberOfElements + + ", totalElements=" + totalElements + + ", totalPages=" + totalPages + + '}'; + } + } +} diff --git a/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationUpdateModel.java b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationUpdateModel.java new file mode 100644 index 00000000..666d80d1 --- /dev/null +++ b/events_mgmt/src/main/java/com/adobe/aio/event/management/model/RegistrationUpdateModel.java @@ -0,0 +1,187 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; +import org.apache.commons.lang3.StringUtils; + +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class RegistrationUpdateModel { + + protected String name; + + protected String description; + + @JsonProperty("webhook_url") + protected String webhookUrl; + + @JsonProperty("events_of_interest") + protected Set eventsOfInterestInputModels; + + @JsonProperty("delivery_type") + protected String deliveryType; + + @JsonProperty("enabled") + protected Boolean enabled; + + public RegistrationUpdateModel(final String name, final String description, final String webhookUrl, + final Set eventsOfInterestInputModels, final String deliveryType, + final Boolean enabled) { + + if (StringUtils.isBlank(name)){ + throw new IllegalArgumentException("Registration is missing a name"); + } + + if (StringUtils.isBlank(deliveryType)){ + throw new IllegalArgumentException("Registration is missing a delivery_type"); + } + + this.name = name; + this.description = description; + this.webhookUrl = webhookUrl; + this.eventsOfInterestInputModels = eventsOfInterestInputModels; + if (DeliveryType.fromFriendlyName(deliveryType).isWebhookDelivery() && StringUtils.isEmpty(webhookUrl)) { + throw new IllegalArgumentException( + "Registration is a webhook registration, but missing a webhook url"); + } else { + this.deliveryType = deliveryType; + } + this.enabled = enabled == null || enabled; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String getWebhookUrl() { + return webhookUrl; + } + + public Set getEventsOfInterests() { + return eventsOfInterestInputModels; + } + + public Boolean isEnabled() { + return enabled; + } + + public String getDeliveryType() { + return deliveryType; + } + + @Override public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof RegistrationUpdateModel)) { + return false; + } + RegistrationUpdateModel that = (RegistrationUpdateModel) o; + return Objects.equals(name, that.name) && + Objects.equals(description, that.description) && + Objects.equals(webhookUrl, that.webhookUrl) && + Objects.equals(eventsOfInterestInputModels, that.eventsOfInterestInputModels) && + Objects.equals(deliveryType, that.deliveryType) && + Objects.equals(enabled, that.enabled); + } + + @Override + public int hashCode() { + return Objects.hash(name, description, webhookUrl, eventsOfInterestInputModels, deliveryType, enabled); + } + + @Override + public String toString() { + return "RegistrationUpdateModel{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", webhookUrl='" + webhookUrl + '\'' + + ", eventsOfInterestInputModels=" + eventsOfInterestInputModels + + ", deliveryType=" + deliveryType + + ", enabled='" + enabled + '\'' + + '}'; + } + + @JsonIgnore + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + protected String name; + protected String description; + protected String deliveryType; + protected Set eventsOfInterestInputModels = new HashSet<>(); + protected String webhookUrl; + protected Boolean enabled = Boolean.TRUE; + + public Builder() { + } + + public T name(String name) { + this.name = name; + return (T) this; + } + + public T description(String description) { + this.description = description; + return (T) this; + } + + public T deliveryType(String deliveryType) { + this.deliveryType = deliveryType; + return (T) this; + } + + public T addEventsOfInterests( + EventsOfInterestInputModel eventsOfInterestInputModel) { + this.eventsOfInterestInputModels.add(eventsOfInterestInputModel); + return (T) this; + } + + public T addEventsOfInterests( + Set eventsOfInterestInputModel) { + this.eventsOfInterestInputModels.addAll(eventsOfInterestInputModel); + return (T) this; + } + + public T webhookUrl(String webhookUrl) { + this.webhookUrl = webhookUrl; + return (T) this; + } + + public T enabled(Boolean enabled) { + this.enabled = enabled; + return (T) this; + } + + public RegistrationUpdateModel build() { + return new RegistrationUpdateModel(name, description, webhookUrl, + eventsOfInterestInputModels, deliveryType, + enabled); + } + } +} + diff --git a/events_mgmt/src/test/java/com/adobe/aio/event/management/feign/FeignRegistrationServiceTestDrive.java b/events_mgmt/src/test/java/com/adobe/aio/event/management/feign/FeignRegistrationServiceTestDrive.java index 9d62c8e4..d214b959 100644 --- a/events_mgmt/src/test/java/com/adobe/aio/event/management/feign/FeignRegistrationServiceTestDrive.java +++ b/events_mgmt/src/test/java/com/adobe/aio/event/management/feign/FeignRegistrationServiceTestDrive.java @@ -12,11 +12,11 @@ package com.adobe.aio.event.management.feign; import com.adobe.aio.event.management.RegistrationService; +import com.adobe.aio.event.management.model.RegistrationCreateModel; import com.adobe.aio.util.WorkspaceUtil; import com.adobe.aio.workspace.Workspace; -import com.adobe.aio.event.management.model.EventsOfInterest; +import com.adobe.aio.event.management.model.EventsOfInterestInputModel; import com.adobe.aio.event.management.model.Registration; -import com.adobe.aio.event.management.model.RegistrationInputModel; import java.util.Optional; import org.slf4j.Logger; @@ -43,12 +43,14 @@ public static void main(String[] args) { logger.info("someRegistration: {}", registration); Optional created = registrationService.createRegistration( - RegistrationInputModel.builder() - .description("your registration description") - .name("your registration name") - .addEventsOfInterests(EventsOfInterest.builder() - .eventCode(SOME_EVENT_CODE) - .providerId(SOME_PROVIDER_ID).build()) + RegistrationCreateModel.builder() + .description("your registration description") + .name("your registration name") + .deliveryType("journal") + .clientId(workspace.getApiKey()) + .addEventsOfInterests(EventsOfInterestInputModel.builder() + .eventCode(SOME_EVENT_CODE) + .providerId(SOME_PROVIDER_ID).build()) ); String createdId = created.get().getRegistrationId(); logger.info("created: {}", created.get()); diff --git a/events_mgmt/src/test/java/com/adobe/aio/event/management/model/EventsOfInterestTest.java b/events_mgmt/src/test/java/com/adobe/aio/event/management/model/EventsOfInterestInputModelTest.java similarity index 70% rename from events_mgmt/src/test/java/com/adobe/aio/event/management/model/EventsOfInterestTest.java rename to events_mgmt/src/test/java/com/adobe/aio/event/management/model/EventsOfInterestInputModelTest.java index e35c4337..c96b09f2 100644 --- a/events_mgmt/src/test/java/com/adobe/aio/event/management/model/EventsOfInterestTest.java +++ b/events_mgmt/src/test/java/com/adobe/aio/event/management/model/EventsOfInterestInputModelTest.java @@ -14,32 +14,32 @@ import org.junit.Assert; import org.junit.Test; -public class EventsOfInterestTest { +public class EventsOfInterestInputModelTest { @Test(expected = IllegalArgumentException.class) public void invalidEmpty() { - EventsOfInterest.builder().build(); + EventsOfInterestInputModel.builder().build(); } @Test(expected = IllegalArgumentException.class) public void invalidMissingProviderId() { - EventsOfInterest.builder().eventCode("some.event.code").build(); + EventsOfInterestInputModel.builder().eventCode("some.event.code").build(); } @Test(expected = IllegalArgumentException.class) public void invalidMissingEventCode() { - EventsOfInterest.builder().providerId("someId").build(); + EventsOfInterestInputModel.builder().providerId("someId").build(); } @Test public void valid() { String eventCode = "com.adobe.aio.event.management.test.event"; String providerId = "some_provider_id"; - EventsOfInterest eventsOfInterest = EventsOfInterest.builder() + EventsOfInterestInputModel eventsOfInterestInputModel = EventsOfInterestInputModel.builder() .eventCode(eventCode) .providerId(providerId).build(); - Assert.assertEquals(eventCode, eventsOfInterest.getEventCode()); - Assert.assertEquals(providerId, eventsOfInterest.getProviderId()); + Assert.assertEquals(eventCode, eventsOfInterestInputModel.getEventCode()); + Assert.assertEquals(providerId, eventsOfInterestInputModel.getProviderId()); } } diff --git a/events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationInputModelTest.java b/events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationCreateModelTest.java similarity index 53% rename from events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationInputModelTest.java rename to events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationCreateModelTest.java index bfd53149..eba5ca03 100644 --- a/events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationInputModelTest.java +++ b/events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationCreateModelTest.java @@ -14,36 +14,61 @@ import org.junit.Assert; import org.junit.Test; -public class RegistrationInputModelTest { +public class RegistrationCreateModelTest { @Test(expected = IllegalArgumentException.class) public void invalidEmpty() { - RegistrationInputModel.builder().build(); + RegistrationCreateModel.builder().build(); } @Test(expected = IllegalArgumentException.class) public void invalidMissingClientId() { - RegistrationInputModel registrationInputModel = RegistrationInputModel.builder() + RegistrationCreateModel registrationInputModel = RegistrationCreateModel.builder() .name("some name") - .description("some description").build(); + .description("some description") + .build(); } @Test(expected = IllegalArgumentException.class) public void invalidMissingName() { - RegistrationInputModel.builder() + RegistrationCreateModel.builder() .description("some description") .clientId("some client Id").build(); } - @Test - public void valid() { + @Test(expected = IllegalArgumentException.class) + public void missingDeliveryType() { String name = "com.adobe.aio.event.management.test.registration"; String description = name + " description"; String clientId = "some_clientId"; - RegistrationInputModel registrationInputModel = RegistrationInputModel.builder() + RegistrationCreateModel registrationInputModel = RegistrationCreateModel.builder() .name(name) .description(description) .clientId(clientId).build(); + } + + @Test(expected = IllegalArgumentException.class) + public void invalidWebhookUrlMissing() { + String name = "com.adobe.aio.event.management.test.registration"; + String description = name + " description"; + String clientId = "some_clientId"; + RegistrationCreateModel registrationInputModel = RegistrationCreateModel.builder() + .name(name) + .description(description) + .clientId(clientId) + .deliveryType("webhook").build(); + } + + @Test + public void valid() { + String name = "com.adobe.aio.event.management.test.registration"; + String description = name + " description"; + String clientId = "some_clientId"; + RegistrationCreateModel registrationInputModel = RegistrationCreateModel.builder() + .name(name) + .description(description) + .clientId(clientId) + .deliveryType("journal").build(); Assert.assertEquals(clientId, registrationInputModel.getClientId()); Assert.assertEquals(name, registrationInputModel.getName()); Assert.assertEquals(description, registrationInputModel.getDescription()); diff --git a/events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationUpdateModelTest.java b/events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationUpdateModelTest.java new file mode 100644 index 00000000..06691040 --- /dev/null +++ b/events_mgmt/src/test/java/com/adobe/aio/event/management/model/RegistrationUpdateModelTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2017 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.adobe.aio.event.management.model; + +import org.junit.Assert; +import org.junit.Test; + +public class RegistrationUpdateModelTest { + + public static final String NAME = "com.adobe.aio.event.management.test.registration"; + public static final String DESCRIPTION = NAME + " description"; + public static final String DELIVERY_TYPE = "journal"; + + @Test(expected = IllegalArgumentException.class) + public void invalidEmpty() { + RegistrationCreateModel.builder().build(); + } + + + @Test(expected = IllegalArgumentException.class) + public void invalidMissingName() { + RegistrationUpdateModel.builder() + .description(DESCRIPTION) + .build(); + } + + @Test(expected = IllegalArgumentException.class) + public void missingDeliveryType() { + RegistrationUpdateModel.builder() + .name(NAME) + .description(DESCRIPTION) + .build(); + } + + @Test(expected = IllegalArgumentException.class) + public void invalidWebhookUrlMissing() { + RegistrationUpdateModel.builder() + .name(NAME) + .description(DESCRIPTION) + .deliveryType("webhook").build(); + } + + @Test + public void valid() { + RegistrationUpdateModel registrationInputModel = RegistrationUpdateModel.builder() + .name(NAME) + .description(DESCRIPTION) + .deliveryType(DELIVERY_TYPE).build(); + Assert.assertEquals(NAME, registrationInputModel.getName()); + Assert.assertEquals(DESCRIPTION, registrationInputModel.getDescription()); + } +} diff --git a/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java b/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java index f9419b11..6c84b03d 100644 --- a/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java +++ b/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java @@ -11,13 +11,10 @@ */ package com.adobe.aio.event.management; -import static com.adobe.aio.event.management.ProviderServiceTester.DEFAULT_DESC_SUFFIX; - import com.adobe.aio.event.management.model.EventsOfInterest; +import com.adobe.aio.event.management.model.EventsOfInterestInputModel; import com.adobe.aio.event.management.model.Registration; -import com.adobe.aio.event.management.model.Registration.IntegrationStatus; -import com.adobe.aio.event.management.model.Registration.Status; -import com.adobe.aio.event.management.model.RegistrationInputModel; +import com.adobe.aio.event.management.model.RegistrationCreateModel; import com.adobe.aio.util.WorkspaceUtil; import com.adobe.aio.workspace.Workspace; import java.net.MalformedURLException; @@ -30,6 +27,8 @@ public class RegistrationServiceTester { + public static final String TEST_DESCRIPTION = "Test description"; + public static final String DELIVERY_TYPE_JOURNAL = "journal"; protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Workspace workspace; protected final RegistrationService registrationService; @@ -42,47 +41,48 @@ public RegistrationServiceTester() { .build(); } - public static RegistrationInputModel.Builder getRegistrationInputModelBuilder( - String registrationName) { - return RegistrationInputModel.builder() - .name(registrationName) - .description(registrationName + DEFAULT_DESC_SUFFIX); + public static EventsOfInterestInputModel.Builder getTestEventsOfInterestBuilder(String providerId, String eventCode) { + return EventsOfInterestInputModel.builder() + .eventCode(eventCode) + .providerId(providerId); } public Registration createJournalRegistration(String registrationName, String providerId, String eventCode){ - return createRegistration(getRegistrationInputModelBuilder(registrationName) - .addEventsOfInterests(EventsOfInterest.builder() - .eventCode(eventCode) - .providerId(providerId).build())); + return createRegistration(RegistrationCreateModel.builder() + .name(registrationName) + .description(TEST_DESCRIPTION) + .deliveryType(DELIVERY_TYPE_JOURNAL) + .addEventsOfInterests(getTestEventsOfInterestBuilder(providerId, eventCode).build())); } - public Registration createRegistration( - RegistrationInputModel.Builder registrationInputModelBuilder) { - RegistrationInputModel registrationInputModel = + public Registration createRegistration( + RegistrationCreateModel.Builder registrationInputModelBuilder) { + RegistrationCreateModel registrationInputModel = registrationInputModelBuilder.clientId(this.workspace.getApiKey()).build(); - Optional registration = registrationService.createRegistration( - registrationInputModelBuilder); + Optional registration = registrationService.createRegistration(registrationInputModelBuilder); Assert.assertTrue(registration.isPresent()); + var registratinCreated = registration.get(); logger.info("Created AIO Event Registration: {}", registration.get()); - String registrationId = registration.get().getRegistrationId(); + String registrationId = registratinCreated.getRegistrationId(); Assert.assertNotNull(registrationId); - String createdId = registration.get().getRegistrationId(); - Assert.assertEquals(registrationInputModel.getDescription(), registration.get().getDescription()); - Assert.assertEquals(registrationInputModel.getName(), registration.get().getName()); - Assert.assertEquals(registrationInputModel.getDeliveryType(), registration.get().getDeliveryType()); + Assert.assertEquals(registrationInputModel.getDescription(), registratinCreated.getDescription()); + Assert.assertEquals(registrationInputModel.getName(), registratinCreated.getName()); + Assert.assertEquals(registrationInputModel.getDeliveryType(), registratinCreated.getDeliveryType()); Set eventsOfInterestSet = registration.get().getEventsOfInterests(); Assert.assertEquals(registrationInputModel.getEventsOfInterests().size(),eventsOfInterestSet.size()); - for(EventsOfInterest eventsOfInterestInput: registrationInputModel.getEventsOfInterests()){ - eventsOfInterestSet.contains(eventsOfInterestInput); + for(var eventsOfInterestInput: registrationInputModel.getEventsOfInterests()){ + Assert.assertTrue(eventsOfInterestSet.stream() + .anyMatch(eventsOfInterest -> eventsOfInterest.getEventCode() + .equals(eventsOfInterestInput.getEventCode()))); } - Assert.assertEquals(Status.VERIFIED, registration.get().getStatus()); - Assert.assertEquals(IntegrationStatus.ENABLED, registration.get().getIntegrationStatus()); + Assert.assertEquals("verified", registratinCreated.getWebhookStatus()); + Assert.assertEquals(true, registratinCreated.isEnabled()); Assert.assertNull(registration.get().getWebhookUrl()); - assertUrl(registration.get().getJournalUrl()); - assertUrl(registration.get().getTraceUrl()); + assertUrl(registration.get().getEventsUrl().getHref()); + assertUrl(registration.get().getTraceUrl().getHref()); Assert.assertNotNull(registration.get().getCreatedDate()); Assert.assertNotNull(registration.get().getUpdatedDate()); Assert.assertEquals(registration.get().getUpdatedDate(), registration.get().getCreatedDate()); diff --git a/events_test/src/test/java/com/adobe/aio/event/journal/JournalServiceIntegrationTest.java b/events_test/src/test/java/com/adobe/aio/event/journal/JournalServiceIntegrationTest.java index 7ecc8de7..8cf511a7 100644 --- a/events_test/src/test/java/com/adobe/aio/event/journal/JournalServiceIntegrationTest.java +++ b/events_test/src/test/java/com/adobe/aio/event/journal/JournalServiceIntegrationTest.java @@ -67,10 +67,10 @@ public void testJournalPolling() String cloudEventId = publishServiceTester.publishCloudEvent(providerId, TEST_EVENT_CODE); boolean wasCloudEventPolled = pollJournalForEvent( - registration.getJournalUrl(), cloudEventId, isEventIdTheCloudEventId); + registration.getEventsUrl().getHref(), cloudEventId, isEventIdTheCloudEventId); String rawEventId = publishServiceTester.publishRawEvent(providerId, TEST_EVENT_CODE); - boolean wasRawEventPolled = pollJournalForEvent(registration.getJournalUrl(), rawEventId, + boolean wasRawEventPolled = pollJournalForEvent(registration.getEventsUrl().getHref(), rawEventId, isEventIdInTheCloudEventData); Assert.assertTrue("The published CloudEvent was not retrieved in the Journal", diff --git a/events_test/src/test/java/com/adobe/aio/event/management/RegistrationServiceIntegrationTest.java b/events_test/src/test/java/com/adobe/aio/event/management/RegistrationServiceIntegrationTest.java index 0ed4583d..37015a0f 100644 --- a/events_test/src/test/java/com/adobe/aio/event/management/RegistrationServiceIntegrationTest.java +++ b/events_test/src/test/java/com/adobe/aio/event/management/RegistrationServiceIntegrationTest.java @@ -63,12 +63,11 @@ public void createGetDeleteJournalRegistration() { Assert.assertEquals(registration.getDeliveryType(), found.get().getDeliveryType()); Assert.assertEquals(registration.getEventsOfInterests(), found.get().getEventsOfInterests()); - Assert.assertEquals(registration.getStatus(), found.get().getStatus()); - Assert.assertEquals(registration.getIntegrationStatus(), - found.get().getIntegrationStatus()); + Assert.assertEquals(registration.getWebhookStatus(), found.get().getWebhookStatus()); + Assert.assertEquals(registration.isEnabled(), found.get().isEnabled()); Assert.assertEquals(registration.getWebhookUrl(), found.get().getWebhookUrl()); - Assert.assertEquals(registration.getJournalUrl(), found.get().getJournalUrl()); - Assert.assertEquals(registration.getTraceUrl(), found.get().getTraceUrl()); + Assert.assertEquals(registration.getEventsUrl().getHref(), found.get().getEventsUrl().getHref()); + Assert.assertEquals(registration.getTraceUrl().getHref(), found.get().getTraceUrl().getHref()); } catch (Exception e) { logger.error(e.getMessage(), e); Assert.fail(e.getMessage()); diff --git a/pom.xml b/pom.xml index 4a30e121..b8c88e59 100644 --- a/pom.xml +++ b/pom.xml @@ -106,6 +106,10 @@ [1.7.21,1.7.25] 2.12.3 0.11.2 + 1.2.0 + + + 1.0.9 11.2 3.8.0 @@ -130,6 +134,12 @@ ${commons-text.version} + + io.cloudevents + cloudevents-api + ${cloudevents.version} + + org.apache.commons commons-lang3 @@ -137,6 +147,18 @@ provided + + io.openapitools.jackson.dataformat + jackson-dataformat-hal + ${jackson-dataformat-hal.version} + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + + + + org.slf4j slf4j-api