-
Notifications
You must be signed in to change notification settings - Fork 20
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
refactoring registration and provider service to make it resilient for conflict errors #200
Changes from all commits
8022b20
b92002b
d3e3db3
8f19718
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
import java.util.Optional; | ||
|
||
import java.util.function.Supplier; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import com.adobe.aio.event.management.model.Registration; | ||
|
@@ -51,24 +52,19 @@ public void createGetDeleteJournalRegistration() { | |
try { | ||
providerId = providerServiceTester.createOrUpdateProvider(TEST_EVENT_PROVIDER_LABEL, | ||
TEST_EVENT_CODE).getId(); | ||
Registration registration = createJournalRegistration(TEST_REGISTRATION_NAME, providerId, | ||
Registration registration = createOrUpdateJournalRegistration(TEST_REGISTRATION_NAME, providerId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may be we could test both path ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't get this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
TEST_EVENT_CODE); | ||
registrationId = registration.getRegistrationId(); | ||
Optional<Registration> found = registrationService.findById(registrationId); | ||
assertTrue(found.isPresent()); | ||
logger.info("Found AIO Event Registration: {}", found.get()); | ||
assertEquals(registrationId, found.get().getRegistrationId()); | ||
assertEquals(registration.getClientId(), found.get().getClientId()); | ||
assertEquals(registration.getDescription(), found.get().getDescription()); | ||
assertEquals(registration.getName(), found.get().getName()); | ||
assertEquals(registration.getDeliveryType(), found.get().getDeliveryType()); | ||
assertEquals(registration.getEventsOfInterests(), | ||
found.get().getEventsOfInterests()); | ||
assertEquals(registration.getWebhookStatus(), found.get().getWebhookStatus()); | ||
assertEquals(registration.isEnabled(), found.get().isEnabled()); | ||
assertEquals(registration.getWebhookUrl(), found.get().getWebhookUrl()); | ||
assertEquals(registration.getJournalUrl().getHref(), found.get().getJournalUrl().getHref()); | ||
assertEquals(registration.getTraceUrl().getHref(), found.get().getTraceUrl().getHref()); | ||
String finalRegistrationId = registration.getRegistrationId(); | ||
assertCreatedOrUpdatedRegistrationMatchesWithFoundRegistration(registration, | ||
() -> registrationService.findById(finalRegistrationId)); | ||
|
||
// covering the update path | ||
registration = createOrUpdateJournalRegistration(TEST_REGISTRATION_NAME, providerId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you add the same coverage for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well,I have done this here in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh I did not catch this, thanks ! |
||
TEST_EVENT_CODE); | ||
String finalUpdatedRegistrationId = registration.getRegistrationId(); | ||
assertCreatedOrUpdatedRegistrationMatchesWithFoundRegistration(registration, | ||
() -> registrationService.findById(finalUpdatedRegistrationId)); | ||
} catch (Exception e) { | ||
logger.error(e.getMessage(), e); | ||
fail(e.getMessage()); | ||
|
@@ -81,4 +77,23 @@ public void createGetDeleteJournalRegistration() { | |
} | ||
} | ||
} | ||
|
||
public void assertCreatedOrUpdatedRegistrationMatchesWithFoundRegistration(Registration registration, | ||
Supplier<Optional<Registration>> foundRegistrationSupplier) { | ||
Optional<Registration> foundRegistrationOptional = foundRegistrationSupplier.get(); | ||
assertTrue(foundRegistrationOptional.isPresent()); | ||
logger.info("Found AIO Event Registration: {}", foundRegistrationOptional.get()); | ||
assertEquals(registration.getRegistrationId(), foundRegistrationOptional.get().getRegistrationId()); | ||
assertEquals(registration.getClientId(), foundRegistrationOptional.get().getClientId()); | ||
assertEquals(registration.getDescription(), foundRegistrationOptional.get().getDescription()); | ||
assertEquals(registration.getName(), foundRegistrationOptional.get().getName()); | ||
assertEquals(registration.getDeliveryType(), foundRegistrationOptional.get().getDeliveryType()); | ||
assertEquals(registration.getEventsOfInterests(), | ||
foundRegistrationOptional.get().getEventsOfInterests()); | ||
assertEquals(registration.getWebhookStatus(), foundRegistrationOptional.get().getWebhookStatus()); | ||
assertEquals(registration.isEnabled(), foundRegistrationOptional.get().isEnabled()); | ||
assertEquals(registration.getWebhookUrl(), foundRegistrationOptional.get().getWebhookUrl()); | ||
assertEquals(registration.getJournalUrl().getHref(), foundRegistrationOptional.get().getJournalUrl().getHref()); | ||
assertEquals(registration.getTraceUrl().getHref(), foundRegistrationOptional.get().getTraceUrl().getHref()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here