Skip to content

Commit

Permalink
test: #1606 ContextLoaderListener not initialized during controller t…
Browse files Browse the repository at this point in the history
…ests

Check if `EnvironmentContextLoaderListener.PROPERTIES` is empty.
  • Loading branch information
nya-elimu committed Aug 6, 2022
1 parent d3e1e47 commit 9087b48
Show file tree
Hide file tree
Showing 28 changed files with 383 additions and 321 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ public String handleSubmit(
if (StringUtils.isBlank(contributor.getMotivation())) {
// The Contributor completed the on-boarding wizard for the first time

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/contributor/" + contributor.getId();
String embedThumbnailUrl = null;
if (StringUtils.isNotBlank(contributor.getImageUrl())) {
embedThumbnailUrl = contributor.getImageUrl();
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/contributor/" + contributor.getId();
String embedThumbnailUrl = null;
if (StringUtils.isNotBlank(contributor.getImageUrl())) {
embedThumbnailUrl = contributor.getImageUrl();
}
DiscordHelper.sendChannelMessage(
"Contributor joined: " + contentUrl,
contributor.getFirstName() + " " + contributor.getLastName(),
"Motivation: \"" + motivation + "\"",
null,
embedThumbnailUrl
);
}
DiscordHelper.sendChannelMessage(
"Contributor joined: " + contentUrl,
contributor.getFirstName() + " " + contributor.getLastName(),
"Motivation: \"" + motivation + "\"",
null,
embedThumbnailUrl
);
}

contributor.setMotivation(motivation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ public String handleSubmit(
letterContributionEvent.setPlatform(Platform.WEBAPP);
letterContributionEventDao.create(letterContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letter/edit/" + letter.getId();
DiscordHelper.sendChannelMessage(
"Letter created: " + contentUrl,
"\"" + letterContributionEvent.getLetter().getText() + "\"",
"Comment: \"" + letterContributionEvent.getComment() + "\"",
null,
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letter/edit/" + letter.getId();
DiscordHelper.sendChannelMessage(
"Letter created: " + contentUrl,
"\"" + letterContributionEvent.getLetter().getText() + "\"",
"Comment: \"" + letterContributionEvent.getComment() + "\"",
null,
null
);
}

return "redirect:/content/letter/list#" + letter.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ public String handleSubmit(
letterContributionEvent.setPlatform(Platform.WEBAPP);
letterContributionEventDao.create(letterContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letter/edit/" + letter.getId();
DiscordHelper.sendChannelMessage(
"Letter edited: " + contentUrl,
"\"" + letterContributionEvent.getLetter().getText() + "\"",
"Comment: \"" + letterContributionEvent.getComment() + "\"",
null,
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letter/edit/" + letter.getId();
DiscordHelper.sendChannelMessage(
"Letter edited: " + contentUrl,
"\"" + letterContributionEvent.getLetter().getText() + "\"",
"Comment: \"" + letterContributionEvent.getComment() + "\"",
null,
null
);
}

return "redirect:/content/letter/list#" + letter.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ public String handleSubmit(
letterSoundCorrespondenceContributionEvent.setPlatform(Platform.WEBAPP);
letterSoundCorrespondenceContributionEventDao.create(letterSoundCorrespondenceContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letter-sound-correspondence/edit/" + letterSoundCorrespondence.getId();
DiscordHelper.sendChannelMessage(
"Letter-sound correspondence created: " + contentUrl,
"\"" + letterSoundCorrespondence.getLetters().stream().map(Letter::getText).collect(Collectors.joining()) + "\"",
"Comment: \"" + letterSoundCorrespondenceContributionEvent.getComment() + "\"",
null,
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letter-sound-correspondence/edit/" + letterSoundCorrespondence.getId();
DiscordHelper.sendChannelMessage(
"Letter-sound correspondence created: " + contentUrl,
"\"" + letterSoundCorrespondence.getLetters().stream().map(Letter::getText).collect(Collectors.joining()) + "\"",
"Comment: \"" + letterSoundCorrespondenceContributionEvent.getComment() + "\"",
null,
null
);
}

return "redirect:/content/letter-sound-correspondence/list#" + letterSoundCorrespondence.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,16 @@ public String handleSubmit(
letterSoundCorrespondenceContributionEvent.setPlatform(Platform.WEBAPP);
letterSoundCorrespondenceContributionEventDao.create(letterSoundCorrespondenceContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letter-sound-correspondence/edit/" + letterSoundCorrespondence.getId();
DiscordHelper.sendChannelMessage(
"Letter-sound correspondence edited: " + contentUrl,
"\"" + letterSoundCorrespondence.getLetters().stream().map(Letter::getText).collect(Collectors.joining()) + "\"",
"Comment: \"" + letterSoundCorrespondenceContributionEvent.getComment() + "\"",
null,
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/letter-sound-correspondence/edit/" + letterSoundCorrespondence.getId();
DiscordHelper.sendChannelMessage(
"Letter-sound correspondence edited: " + contentUrl,
"\"" + letterSoundCorrespondence.getLetters().stream().map(Letter::getText).collect(Collectors.joining()) + "\"",
"Comment: \"" + letterSoundCorrespondenceContributionEvent.getComment() + "\"",
null,
null
);
}

return "redirect:/content/letter-sound-correspondence/list#" + letterSoundCorrespondence.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,16 @@ public String handleSubmit(
audioContributionEvent.setPlatform(Platform.WEBAPP);
audioContributionEventDao.create(audioContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/audio/edit/" + audio.getId();
DiscordHelper.sendChannelMessage(
"Audio created: " + contentUrl,
"\"" + audio.getTranscription() + "\"",
"Comment: \"" + audioContributionEvent.getComment() + "\"",
null,
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/audio/edit/" + audio.getId();
DiscordHelper.sendChannelMessage(
"Audio created: " + contentUrl,
"\"" + audio.getTranscription() + "\"",
"Comment: \"" + audioContributionEvent.getComment() + "\"",
null,
null
);
}

return "redirect:/content/multimedia/audio/list#" + audio.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,16 @@ public String handleSubmit(
audioContributionEvent.setPlatform(Platform.WEBAPP);
audioContributionEventDao.create(audioContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/audio/edit/" + audio.getId();
DiscordHelper.sendChannelMessage(
"Audio edited: " + contentUrl,
"\"" + audio.getTranscription() + "\"",
"Comment: \"" + audioContributionEvent.getComment() + "\"",
null,
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/audio/edit/" + audio.getId();
DiscordHelper.sendChannelMessage(
"Audio edited: " + contentUrl,
"\"" + audio.getTranscription() + "\"",
"Comment: \"" + audioContributionEvent.getComment() + "\"",
null,
null
);
}

return "redirect:/content/multimedia/audio/list#" + audio.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,17 @@ public String handleSubmit(
imageContributionEvent.setPlatform(Platform.WEBAPP);
imageContributionEventDao.create(imageContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
String embedThumbnailUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/image/" + image.getId() + "_r" + image.getRevisionNumber() + "." + image.getImageFormat().toString().toLowerCase();
DiscordHelper.sendChannelMessage(
"Image created: " + contentUrl,
"\"" + image.getTitle() + "\"",
"Comment: \"" + imageContributionEvent.getComment() + "\"",
null,
embedThumbnailUrl
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
String embedThumbnailUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/image/" + image.getId() + "_r" + image.getRevisionNumber() + "." + image.getImageFormat().toString().toLowerCase();
DiscordHelper.sendChannelMessage(
"Image created: " + contentUrl,
"\"" + image.getTitle() + "\"",
"Comment: \"" + imageContributionEvent.getComment() + "\"",
null,
embedThumbnailUrl
);
}

return "redirect:/content/multimedia/image/list#" + image.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,17 @@ public String handleSubmit(
imageContributionEvent.setPlatform(Platform.WEBAPP);
imageContributionEventDao.create(imageContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
String embedThumbnailUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/image/" + image.getId() + "_r" + image.getRevisionNumber() + "." + image.getImageFormat().toString().toLowerCase();
DiscordHelper.sendChannelMessage(
"Image edited: " + contentUrl,
"\"" + image.getTitle() + "\"",
"Comment: \"" + imageContributionEvent.getComment() + "\"",
null,
embedThumbnailUrl
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/image/edit/" + image.getId();
String embedThumbnailUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/image/" + image.getId() + "_r" + image.getRevisionNumber() + "." + image.getImageFormat().toString().toLowerCase();
DiscordHelper.sendChannelMessage(
"Image edited: " + contentUrl,
"\"" + image.getTitle() + "\"",
"Comment: \"" + imageContributionEvent.getComment() + "\"",
null,
embedThumbnailUrl
);
}

return "redirect:/content/multimedia/image/list#" + image.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@ public String handleSubmit(
numberContributionEvent.setPlatform(Platform.WEBAPP);
numberContributionEventDao.create(numberContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/number/edit/" + number.getId();
DiscordHelper.sendChannelMessage(
"Number created: " + contentUrl,
String.valueOf(numberContributionEvent.getNumber().getValue()),
"Comment: \"" + numberContributionEvent.getComment() + "\"",
null,
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/number/edit/" + number.getId();
DiscordHelper.sendChannelMessage(
"Number created: " + contentUrl,
String.valueOf(numberContributionEvent.getNumber().getValue()),
"Comment: \"" + numberContributionEvent.getComment() + "\"",
null,
null
);
}

return "redirect:/content/number/list#" + number.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ public String handleSubmit(
numberContributionEvent.setPlatform(Platform.WEBAPP);
numberContributionEventDao.create(numberContributionEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/number/edit/" + number.getId();
DiscordHelper.sendChannelMessage(
"Number edited: " + contentUrl,
String.valueOf(numberContributionEvent.getNumber().getValue()),
"Comment: \"" + numberContributionEvent.getComment() + "\"",
null,
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/number/edit/" + number.getId();
DiscordHelper.sendChannelMessage(
"Number edited: " + contentUrl,
String.valueOf(numberContributionEvent.getNumber().getValue()),
"Comment: \"" + numberContributionEvent.getComment() + "\"",
null,
null
);
}

return "redirect:/content/number/list#" + number.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ public String handleSubmit(
audioPeerReviewEvent.setPlatform(Platform.WEBAPP);
audioPeerReviewEventDao.create(audioPeerReviewEvent);

String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/audio/edit/" + audioContributionEvent.getAudio().getId();
DiscordHelper.sendChannelMessage(
"Audio peer-reviewed: " + contentUrl,
"\"" + audioContributionEvent.getAudio().getTitle() + "\"",
"Comment: \"" + audioPeerReviewEvent.getComment() + "\"",
audioPeerReviewEvent.isApproved(),
null
);
if (!EnvironmentContextLoaderListener.PROPERTIES.isEmpty()) {
String contentUrl = "https://" + EnvironmentContextLoaderListener.PROPERTIES.getProperty("content.language").toLowerCase() + ".elimu.ai/content/multimedia/audio/edit/" + audioContributionEvent.getAudio().getId();
DiscordHelper.sendChannelMessage(
"Audio peer-reviewed: " + contentUrl,
"\"" + audioContributionEvent.getAudio().getTitle() + "\"",
"Comment: \"" + audioPeerReviewEvent.getComment() + "\"",
audioPeerReviewEvent.isApproved(),
null
);
}

// Update the audio's peer review status
int approvedCount = 0;
Expand Down
Loading

0 comments on commit 9087b48

Please sign in to comment.