use of com.formkiq.stacks.common.objects.DynamicObject in project formkiq-core by formkiq.
the class WebhooksServiceImplTest method testFindWebhook02.
/**
* Test Finding missing webhook.
*/
@Test
public void testFindWebhook02() {
// given
for (String siteId : Arrays.asList(null, UUID.randomUUID().toString())) {
String id = UUID.randomUUID().toString();
// when
DynamicObject o = this.service.findWebhook(siteId, id);
// then
assertNull(o);
}
}
use of com.formkiq.stacks.common.objects.DynamicObject in project formkiq-core by formkiq.
the class WebhooksServiceImplTest method testFindWebhook01.
/**
* Test Finding webhook.
*/
@Test
public void testFindWebhook01() {
// given
for (String siteId : Arrays.asList(null, UUID.randomUUID().toString())) {
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
String id = this.service.saveWebhook(siteId, "test", "joe", Date.from(now.toInstant()), "true");
// when
DynamicObject o = this.service.findWebhook(siteId, id);
// then
assertNotNull(o.getString("documentId"));
assertNotNull(o.getString("path"));
assertNotNull(o.getString("userId"));
assertNotNull(o.getString("inserteddate"));
assertNotNull(o.getString("TimeToLive"));
LocalDateTime time = LocalDateTime.ofEpochSecond(Long.parseLong(o.getString("TimeToLive")), 0, ZoneOffset.UTC);
assertEquals(now.getYear(), time.getYear());
assertEquals(now.getMonth(), time.getMonth());
assertEquals(now.getDayOfMonth(), time.getDayOfMonth());
assertEquals(now.getHour(), time.getHour());
assertEquals(now.getMinute(), time.getMinute());
assertEquals(now.getSecond(), time.getSecond());
// when
this.service.deleteWebhook(siteId, id);
// then
assertEquals(0, this.service.findWebhooks(siteId).size());
}
}
use of com.formkiq.stacks.common.objects.DynamicObject in project formkiq-core by formkiq.
the class WebhooksServiceImplTest method testUpdateTimeToLive01.
/**
* Test Updating webhooks Time To Live.
*/
@Test
public void testUpdateTimeToLive01() {
// given
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
Date ttl = Date.from(now.toInstant());
ZonedDateTime tomorrow = ZonedDateTime.now(ZoneOffset.UTC).plusDays(1);
Date tomorrowttl = Date.from(tomorrow.toInstant());
for (String siteId : Arrays.asList(null, UUID.randomUUID().toString())) {
String webhookId = this.service.saveWebhook(siteId, "test", "joe", ttl, "true");
DocumentTag tag0 = new DocumentTag(webhookId, "category", "person", new Date(), "joe");
this.service.addTags(siteId, webhookId, Arrays.asList(tag0), null);
DynamicObject tag = this.service.findTag(siteId, webhookId, "category");
assertNull(tag.getString("TimeToLive"));
// when
this.service.updateTimeToLive(siteId, webhookId, tomorrowttl);
// then
DynamicObject result = this.service.findWebhook(siteId, webhookId);
assertEquals("test", result.getString("path"));
assertNotNull(result.getString("documentId"));
assertNotNull(result.getString("path"));
assertNotNull(result.getString("userId"));
assertNotNull(result.getString("inserteddate"));
assertEquals(String.valueOf(tomorrowttl.getTime() / MILLISECONDS), result.getString("TimeToLive"));
tag = this.service.findTag(siteId, webhookId, "category");
assertNotNull(tag.getString("TimeToLive"));
assertEquals(String.valueOf(tomorrowttl.getTime() / MILLISECONDS), tag.getString("TimeToLive"));
}
}
use of com.formkiq.stacks.common.objects.DynamicObject in project formkiq-core by formkiq.
the class WebhooksServiceImpl method deleteWebhookTags.
private void deleteWebhookTags(final String siteId, final String id, final PaginationMapToken token) {
PaginationResults<DynamicObject> tags = findTags(siteId, id, token);
for (DynamicObject t : tags.getResults()) {
String pk = t.getString("PK");
String sk = t.getString("SK");
Map<String, AttributeValue> key = Map.of("PK", AttributeValue.builder().s(pk).build(), "SK", AttributeValue.builder().s(sk).build());
this.dynamoDB.deleteItem(DeleteItemRequest.builder().tableName(this.documentTableName).key(key).build());
}
if (tags.getToken() != null) {
deleteWebhookTags(siteId, id, tags.getToken());
}
}
use of com.formkiq.stacks.common.objects.DynamicObject in project formkiq-core by formkiq.
the class DocumentsRestrictionsMaxContentLengthTest method testEnforced04.
/**
* Max Content Length, Content Length greater.
*/
@Test
public void testEnforced04() {
// given
Long contentLength = Long.valueOf("15");
String siteId = UUID.randomUUID().toString();
DynamicObject ob = this.awsservice.configService().get(siteId);
ob.put(ConfigService.MAX_DOCUMENT_SIZE_BYTES, "10");
this.awsservice.configService().save(siteId, ob);
// when
String value = service.getValue(this.awsservice, siteId);
boolean result = service.enforced(this.awsservice, siteId, value, contentLength);
// then
assertTrue(result);
}
Aggregations