use of org.orcid.persistence.jpa.entities.WebhookEntity in project ORCID-Source by ORCID.
the class WebhookManagerMultiThreadedTest method testProcessWebhooks.
@Test
public void testProcessWebhooks() {
Date now = new Date();
List<WebhookEntity> webhooks = webhookDao.findWebhooksReadyToProcess(now, 5, 10);
assertEquals(1, webhooks.size());
webhookManager.processWebhooks();
webhooks = webhookDao.findWebhooksReadyToProcess(now, 5, 10);
assertEquals(0, webhooks.size());
}
use of org.orcid.persistence.jpa.entities.WebhookEntity in project ORCID-Source by ORCID.
the class WebhookManagerImplTest method testValidUriOnWebhook.
@Test
public void testValidUriOnWebhook() {
WebhookEntity webhook = new WebhookEntity();
webhook.setClientDetails(clientDetails);
webhook.setUri("http://qa-1.orcid.org");
webhook.setProfile(testProfile);
webhookManager.processWebhook(webhook);
assertEquals(webhook.getFailedAttemptCount(), 0);
verify(mockWebhookDao, times(1)).merge(webhook);
}
use of org.orcid.persistence.jpa.entities.WebhookEntity in project ORCID-Source by ORCID.
the class WebhookManagerImplTest method testInvalidUriOnWebhook.
@Test
public void testInvalidUriOnWebhook() {
WebhookEntity webhook = new WebhookEntity();
webhook.setClientDetails(clientDetails);
webhook.setUri("http://123.qa-1.orcid.org");
webhook.setProfile(testProfile);
webhookManager.processWebhook(webhook);
assertEquals(webhook.getFailedAttemptCount(), 1);
for (int i = 0; i < 3; i++) {
webhookManager.processWebhook(webhook);
}
assertEquals(webhook.getFailedAttemptCount(), 4);
verify(mockWebhookDao, times(4)).merge(webhook);
}
use of org.orcid.persistence.jpa.entities.WebhookEntity in project ORCID-Source by ORCID.
the class WebhookManagerImplTest method testUnexsistingUriOnWebhook.
@Test
public void testUnexsistingUriOnWebhook() {
WebhookEntity webhook = new WebhookEntity();
webhook.setClientDetails(clientDetails);
webhook.setUri("http://unexisting.orcid.com");
webhook.setProfile(testProfile);
webhookManager.processWebhook(webhook);
assertEquals(webhook.getFailedAttemptCount(), 1);
for (int i = 0; i < 3; i++) {
webhookManager.processWebhook(webhook);
}
assertEquals(webhook.getFailedAttemptCount(), 4);
verify(mockWebhookDao, times(4)).merge(webhook);
}
use of org.orcid.persistence.jpa.entities.WebhookEntity in project ORCID-Source by ORCID.
the class WebhookDaoTest method testMergeFindAndRemove.
@Test
@Rollback(true)
public void testMergeFindAndRemove() {
ProfileEntity profile = new ProfileEntity("1234-1234-1234-1234");
profileDao.merge(profile);
ProfileEntity clientProfile = new ProfileEntity("4444-4444-4444-4449");
profileDao.merge(clientProfile);
ClientDetailsEntity clientDetails = new ClientDetailsEntity();
clientDetails.setGroupProfileId(clientProfile.getId());
clientDetails.setId(clientProfile.getId());
clientDetailsDao.merge(clientDetails);
WebhookEntity webhook = new WebhookEntity();
webhook.setProfile(profile);
webhook.setUri("http://semantico.com/orcid/1234");
webhook.setClientDetails(clientDetails);
webhookDao.merge(webhook);
WebhookEntityPk pk = new WebhookEntityPk();
pk.setProfile(profile);
pk.setUri("http://semantico.com/orcid/1234");
WebhookEntity retrieved = webhookDao.find(pk);
assertNotNull(retrieved);
assertEquals("1234-1234-1234-1234", retrieved.getProfile().getId());
assertEquals("http://semantico.com/orcid/1234", retrieved.getUri());
assertEquals("4444-4444-4444-4449", retrieved.getClientDetails().getClientId());
assertTrue(retrieved.isEnabled());
assertEquals(0, retrieved.getFailedAttemptCount());
assertNull(retrieved.getLastFailed());
webhookDao.remove(pk);
retrieved = webhookDao.find(pk);
assertNull(retrieved);
}
Aggregations