Java Code Examples for play.libs.Json#stringify()

The following examples show how to use play.libs.Json#stringify() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmailActionExecutor.java    From remote-monitoring-services-java with MIT License 6 votes vote down vote up
private String generatePayload(EmailActionServiceModel emailAction, AsaAlarmApiModel alarm) {
    DateTime alarmDate = new DateTime(Long.parseLong(alarm.getDateCreated()));
    String emailBody = this.emailTemplate.replace("${subject}", emailAction.getSubject())
        .replace("${notes}", emailAction.getNotes())
        .replace("${alarmDate}", alarmDate.toString(DATE_FORMAT_STRING))
        .replace("${ruleId}", alarm.getRuleId())
        .replace("${ruleDescription}", alarm.getRuleDescription())
        .replace("${ruleSeverity}", alarm.getRuleSeverity())
        .replace("${deviceId}", alarm.getDeviceId())
        .replace("${alarmUrl}", this.generateRuleDetailUrl(alarm.getRuleId()));

    EmailActionPayload payload = new EmailActionPayload(
        emailAction.getRecipients(),
        emailAction.getSubject(),
        emailBody
    );

    return Json.stringify(Json.toJson(payload));
}
 
Example 2
Source File: StorageTest.java    From remote-monitoring-services-java with MIT License 6 votes vote down vote up
@Test(timeout = StorageTest.TIMEOUT)
@Category({UnitTest.class})
public void updateDeviceGroupAsyncTest() throws BaseException, ExecutionException, InterruptedException {
    String groupId = rand.NextString();
    String displayName = rand.NextString();
    Iterable<DeviceGroupCondition> conditions = null;
    String etagOld = rand.NextString();
    String etagNew = rand.NextString();
    DeviceGroup group = new DeviceGroup();
    group.setDisplayName(displayName);
    group.setConditions(conditions);
    ValueApiModel model = new ValueApiModel(groupId, Json.stringify(Json.toJson(group)), etagNew, null);
    Mockito.when(mockClient.updateAsync(Mockito.any(String.class),
            Mockito.any(String.class),
            Mockito.any(String.class),
            Mockito.any(String.class))).
            thenReturn(CompletableFuture.supplyAsync(() -> model));
    DeviceGroup result = storage.updateDeviceGroupAsync(groupId, group, etagOld).toCompletableFuture().get();
    assertEquals(result.getId(), groupId);
    assertEquals(result.getDisplayName(), displayName);
    assertEquals(result.getConditions(), conditions);
    assertEquals(result.getETag(), etagNew);
}
 
Example 3
Source File: SerializableObjectStoringSessionCookieStrategy.java    From commercetools-sunrise-java with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public <U> void overwriteObjectByKey(final String key, @Nullable final U object) {
    if (object != null) {
        final JsonNode jsonNode = Json.toJson(object);
        final String valueAsJson = Json.stringify(jsonNode);
        overwriteValueByKey(key, valueAsJson);
    } else {
        removeValueByKey(key);
    }
}
 
Example 4
Source File: MethodResultServiceModel.java    From remote-monitoring-services-java with MIT License 4 votes vote down vote up
public MethodResultServiceModel(MethodResult result) {
    this.status = result.getStatus();
    this.jsonPayload = Json.stringify(toJson(result.getPayload()));
}
 
Example 5
Source File: HttpRequest.java    From remote-monitoring-services-java with MIT License 4 votes vote down vote up
private static <T> String toJson(T o) {
    return Json.stringify(Json.toJson(o));
}
 
Example 6
Source File: StorageAdapterClient.java    From remote-monitoring-services-java with MIT License 4 votes vote down vote up
private static <T> String toJson(T o) {
    return Json.stringify(Json.toJson(o));
}
 
Example 7
Source File: Storage.java    From remote-monitoring-services-java with MIT License 4 votes vote down vote up
private static <T> String toJson(T o) {
    return Json.stringify(Json.toJson(o));
}
 
Example 8
Source File: ModelTestUtils.java    From ground with Apache License 2.0 4 votes vote down vote up
public static String convertFromClassToString(Object object) {
  return Json.stringify(Json.toJson(object));
}