use of org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllMessagesRequest in project haikudepotserver by haiku.
the class MiscellaneousApiImpl method getAllMessages.
@Override
public GetAllMessagesResult getAllMessages(GetAllMessagesRequest getAllMessagesRequest) {
Preconditions.checkNotNull(getAllMessagesRequest);
Preconditions.checkNotNull(getAllMessagesRequest.naturalLanguageCode);
ObjectContext context = serverRuntime.newContext();
NaturalLanguage naturalLanguage = Optional.ofNullable(getAllMessagesRequest.naturalLanguageCode).filter(StringUtils::isNotBlank).flatMap(c -> NaturalLanguage.tryGetByCode(context, c)).orElseThrow(() -> new ObjectNotFoundException(NaturalLanguage.class.getSimpleName(), getAllMessagesRequest.naturalLanguageCode));
Properties allLocalizationMessages = naturalLanguageService.getAllLocalizationMessages(naturalLanguage.getCode());
GetAllMessagesResult getAllMessagesResult = new GetAllMessagesResult();
getAllMessagesResult.messages = new HashMap<>();
for (Object key : allLocalizationMessages.keySet()) {
getAllMessagesResult.messages.put(key.toString(), allLocalizationMessages.get(key).toString());
}
return getAllMessagesResult;
}
use of org.haiku.haikudepotserver.api1.model.miscellaneous.GetAllMessagesRequest in project haikudepotserver by haiku.
the class MiscelaneousApiIT method testGetAllMessages.
@Test
public void testGetAllMessages() throws Exception {
// ------------------------------------
GetAllMessagesResult result = miscellaneousApi.getAllMessages(new GetAllMessagesRequest(NaturalLanguage.CODE_ENGLISH));
// ------------------------------------
Assertions.assertThat(result.messages.get("test.it")).isEqualTo("Test line for integration testing");
}
Aggregations