Adding more tests. Moving tests to Java. Making tests less brittle.

Adding Jackson annotations for MoviesFromCollection. Added tests to serialize/deserialize.
This commit is contained in:
Jason House
2020-10-07 22:43:10 +09:00
parent 671d64ae98
commit 3e983d98db
48 changed files with 1971 additions and 925 deletions
@@ -1,7 +1,11 @@
package com.jasonhhouse.gaps;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public final class MovieFromCollection {
@NotNull
@@ -11,10 +15,13 @@ public final class MovieFromCollection {
@NotNull
private final Boolean owned;
public MovieFromCollection(@NotNull String title, @NotNull String tmdbId, @NotNull Boolean owned) {
this.title = title;
this.tmdbId = tmdbId;
this.owned = owned;
@JsonCreator
public MovieFromCollection(@JsonProperty(value = "title") @Nullable String title,
@JsonProperty(value = "tmdbId") @Nullable String tmdbId,
@JsonProperty(value = "owned") @Nullable Boolean owned) {
this.title = StringUtils.isEmpty(title) ? "" : title;
this.tmdbId = StringUtils.isEmpty(tmdbId) ? "" : tmdbId;
this.owned = owned != null && owned;
}
@NotNull
@@ -0,0 +1,49 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.properties.DiscordProperties;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class MovieFromCollectionTest {
@NotNull
private ObjectMapper objectMapper;
@BeforeEach
void setUp() {
objectMapper = new ObjectMapper();
}
@Test
void testReadingFromJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":\"123QWE\",\"owned\":true}", MovieFromCollection.class);
assertEquals("TITLE", movieFromCollection.getTitle(), "Title should be 'TITLE'");
assertEquals("123QWE", movieFromCollection.getTmdbId(), "tmdbId should be '123QWE'");
assertTrue(movieFromCollection.getOwned(), "Title should be 'TITLE'");
}
@Test
void testWritingToJson() throws JsonProcessingException {
MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE","123QWE",true);
String json = objectMapper.writeValueAsString(movieFromCollection);
assertEquals("{\"title\":\"TITLE\",\"tmdbId\":\"123QWE\",\"owned\":true}", json, "JSON output should be equal");
}
}
@@ -13,6 +13,8 @@ package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.NotificationProperties;
import com.jasonhhouse.gaps.service.FileIoService;
import com.jasonhhouse.gaps.service.IO;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -22,34 +24,24 @@ public abstract class AbstractNotificationAgent<T extends NotificationProperties
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractNotificationAgent.class);
protected final FileIoService fileIoService;
protected final IO ioService;
protected T t;
protected AbstractNotificationAgent(FileIoService fileIoService) {
this.fileIoService = fileIoService;
protected AbstractNotificationAgent(@NotNull IO ioService) {
this.ioService = ioService;
}
@Override
public boolean isEnabled() {
public @NotNull Boolean isEnabled() {
NotificationProperties notificationProperties = getNotificationProperties();
if (notificationProperties == null) {
return false;
} else {
return notificationProperties.getEnabled();
}
return notificationProperties.getEnabled();
}
protected boolean sendPrepMessage(NotificationType notificationType) {
protected @NotNull Boolean sendPrepMessage(@NotNull NotificationType notificationType) {
LOGGER.info("sendPrepMessage()");
t = getNotificationProperties();
if (t == null) {
LOGGER.warn("Notification Properties are null");
return true;
}
if (!notificationType.equals(NotificationType.TEST) && !t.getNotificationTypes().contains(notificationType)) {
LOGGER.info(AGENT_NOT_ENABLED_FOR_NOTIFICATION_TYPE, getName(), notificationType);
return true;
@@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.DiscordProperties;
import com.jasonhhouse.gaps.service.FileIoService;
import com.jasonhhouse.gaps.service.IO;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
@@ -36,12 +37,15 @@ import static com.jasonhhouse.gaps.notifications.NotificationStatus.TIMEOUT;
public final class DiscordNotificationAgent extends AbstractNotificationAgent<DiscordProperties> {
@NotNull
private static final Logger LOGGER = LoggerFactory.getLogger(DiscordNotificationAgent.class);
@NotNull
private static final ObjectMapper objectMapper = new ObjectMapper();
@NotNull
private final OkHttpClient client;
public DiscordNotificationAgent(FileIoService fileIoService) {
super(fileIoService);
public DiscordNotificationAgent(@NotNull IO ioService) {
super(ioService);
client = new OkHttpClient.Builder()
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
@@ -51,17 +55,17 @@ public final class DiscordNotificationAgent extends AbstractNotificationAgent<Di
}
@Override
public int getId() {
public @NotNull Integer getId() {
return 6;
}
@Override
public String getName() {
public @NotNull String getName() {
return "Discord Notification Agent";
}
@Override
public boolean sendMessage(NotificationType notificationType, String level, String title, String message) {
public @NotNull Boolean sendMessage(@NotNull NotificationType notificationType, @NotNull String level, @NotNull String title, @NotNull String message) {
LOGGER.info("sendMessage( {}, {}, {} )", level, title, message);
if (sendPrepMessage(notificationType)) {
@@ -108,40 +112,42 @@ public final class DiscordNotificationAgent extends AbstractNotificationAgent<Di
}
}
@NotNull
@Override
public DiscordProperties getNotificationProperties() {
return fileIoService.readProperties().getDiscordProperties();
public @NotNull DiscordProperties getNotificationProperties() {
return ioService.readProperties().getDiscordProperties();
}
private static final class Discord {
@NotNull
private final List<Embeds> embeds;
private Discord(String title, String message) {
private Discord(@NotNull String title, @NotNull String message) {
Embeds embed = new Embeds(title, message);
embeds = Collections.singletonList(embed);
}
public List<Embeds> getEmbeds() {
public @NotNull List<Embeds> getEmbeds() {
return embeds;
}
}
private static final class Embeds {
@NotNull
private final String title;
@NotNull
private final String description;
private Embeds(String title, String description) {
private Embeds(@NotNull String title, @NotNull String description) {
this.title = title;
this.description = description;
}
public String getTitle() {
public @NotNull String getTitle() {
return title;
}
public String getDescription() {
public @NotNull String getDescription() {
return description;
}
}
@@ -13,6 +13,7 @@ package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.EmailProperties;
import com.jasonhhouse.gaps.service.FileIoService;
import com.jasonhhouse.gaps.service.IO;
import java.util.Properties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -26,24 +27,26 @@ import static com.jasonhhouse.gaps.notifications.NotificationStatus.SEND_MESSAGE
public final class EmailNotificationAgent extends AbstractNotificationAgent<EmailProperties> {
@NotNull
private static final Logger LOGGER = LoggerFactory.getLogger(EmailNotificationAgent.class);
public EmailNotificationAgent(FileIoService fileIoService) {
super(fileIoService);
@NotNull
public EmailNotificationAgent(@NotNull IO ioService) {
super(ioService);
}
@Override
public int getId() {
public @NotNull Integer getId() {
return 4;
}
@Override
public String getName() {
public @NotNull String getName() {
return "Email Notification Agent";
}
@Override
public boolean sendMessage(NotificationType notificationType, String level, String title, String message) {
public @NotNull Boolean sendMessage(@NotNull NotificationType notificationType, @NotNull String level, @NotNull String title, @NotNull String message) {
LOGGER.info(SEND_MESSAGE, level, title, message);
if (sendPrepMessage(notificationType)) {
@@ -66,10 +69,9 @@ public final class EmailNotificationAgent extends AbstractNotificationAgent<Emai
}
}
@NotNull
@Override
public EmailProperties getNotificationProperties() {
return fileIoService.readProperties().getEmailProperties();
public @NotNull EmailProperties getNotificationProperties() {
return ioService.readProperties().getEmailProperties();
}
private JavaMailSenderImpl getJavaMailSender() {
@@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.GotifyProperties;
import com.jasonhhouse.gaps.service.FileIoService;
import com.jasonhhouse.gaps.service.IO;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.HttpUrl;
@@ -24,7 +25,6 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,12 +34,17 @@ import static com.jasonhhouse.gaps.notifications.NotificationStatus.TIMEOUT;
public final class GotifyNotificationAgent extends AbstractNotificationAgent<GotifyProperties> {
@NotNull
private static final Logger LOGGER = LoggerFactory.getLogger(GotifyNotificationAgent.class);
@NotNull
private static final ObjectMapper objectMapper = new ObjectMapper();
@NotNull
private final OkHttpClient client;
public GotifyNotificationAgent(FileIoService fileIoService) {
super(fileIoService);
public GotifyNotificationAgent(@NotNull IO ioService) {
super(ioService);
client = new OkHttpClient.Builder()
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
@@ -50,17 +55,17 @@ public final class GotifyNotificationAgent extends AbstractNotificationAgent<Got
}
@Override
public int getId() {
public @NotNull Integer getId() {
return 3;
}
@Override
public String getName() {
public @NotNull String getName() {
return "Gotify Notification Agent";
}
@Override
public boolean sendMessage(NotificationType notificationType, String level, String title, String message) {
public @NotNull Boolean sendMessage(@NotNull NotificationType notificationType, @NotNull String level, @NotNull String title, @NotNull String message) {
LOGGER.info(SEND_MESSAGE, level, title, message);
if (sendPrepMessage(notificationType)) {
@@ -102,26 +107,27 @@ public final class GotifyNotificationAgent extends AbstractNotificationAgent<Got
}
}
@NotNull
@Override
public GotifyProperties getNotificationProperties() {
return fileIoService.readProperties().getGotifyProperties();
public @NotNull GotifyProperties getNotificationProperties() {
return ioService.readProperties().getGotifyProperties();
}
public static final class Gotify {
@NotNull
private final String title;
@NotNull
private final String message;
public Gotify(String title, String message) {
public Gotify(@NotNull String title, @NotNull String message) {
this.message = message;
this.title = title;
}
public String getTitle() {
public @NotNull String getTitle() {
return title;
}
public String getMessage() {
public @NotNull String getMessage() {
return message;
}
}
@@ -13,18 +13,16 @@ package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.NotificationProperties;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface NotificationAgent<T extends NotificationProperties> {
int getId();
@NotNull Integer getId();
String getName();
@NotNull String getName();
boolean isEnabled();
@NotNull Boolean isEnabled();
boolean sendMessage(NotificationType notificationType, String level, String title, String message);
@NotNull Boolean sendMessage(@NotNull NotificationType notificationType, @NotNull String level, @NotNull String title, @NotNull String message);
@NotNull
T getNotificationProperties();
@NotNull T getNotificationProperties();
}
@@ -1,12 +1,23 @@
package com.jasonhhouse.gaps.notifications;
import org.jetbrains.annotations.NotNull;
public final class NotificationStatus {
@NotNull
public static final String FAILED_TO_READ_PROPERTIES = "Failed to read %s from Properties file.";
@NotNull
public static final String AGENT_NOT_ENABLED_FOR_NOTIFICATION_TYPE = "{} not enabled for notification type {}";
@NotNull
public static final String FAILED_TO_PARSE_JSON = "Failed to turn %s message into JSON";
@NotNull
public static final String SEND_MESSAGE = "sendMessage( {}, {}, {} )";
public static final long TIMEOUT = 2500;
@NotNull
public static final Long TIMEOUT = 2500L;
private NotificationStatus() {
//No init
@@ -15,6 +15,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.PushBulletProperties;
import com.jasonhhouse.gaps.service.FileIoService;
import com.jasonhhouse.gaps.service.IO;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.Headers;
@@ -25,7 +26,6 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,12 +35,17 @@ import static com.jasonhhouse.gaps.notifications.NotificationStatus.TIMEOUT;
public final class PushBulletNotificationAgent extends AbstractNotificationAgent<PushBulletProperties> {
@NotNull
private static final Logger LOGGER = LoggerFactory.getLogger(PushBulletNotificationAgent.class);
@NotNull
private static final ObjectMapper objectMapper = new ObjectMapper();
@NotNull
private final OkHttpClient client;
public PushBulletNotificationAgent(FileIoService fileIoService) {
super(fileIoService);
public PushBulletNotificationAgent(@NotNull IO ioService) {
super(ioService);
client = new OkHttpClient.Builder()
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
@@ -49,19 +54,18 @@ public final class PushBulletNotificationAgent extends AbstractNotificationAgent
.build();
}
@Override
public int getId() {
public @NotNull Integer getId() {
return 1;
}
@Override
public String getName() {
public @NotNull String getName() {
return "PushBullet Notification Agent";
}
@Override
public boolean sendMessage(NotificationType notificationType, String level, String title, String message) {
public @NotNull Boolean sendMessage(@NotNull NotificationType notificationType, @NotNull String level, @NotNull String title, @NotNull String message) {
LOGGER.info(SEND_MESSAGE, level, title, message);
if (sendPrepMessage(notificationType)) {
@@ -114,19 +118,22 @@ public final class PushBulletNotificationAgent extends AbstractNotificationAgent
}
}
@NotNull
@Override
public PushBulletProperties getNotificationProperties() {
return fileIoService.readProperties().getPushBulletProperties();
public @NotNull PushBulletProperties getNotificationProperties() {
return ioService.readProperties().getPushBulletProperties();
}
public static final class PushBullet {
@NotNull
private final String type;
@NotNull
private final String channelTag;
@NotNull
private final String title;
@NotNull
private final String body;
public PushBullet(String channelTag, String title, String body) {
public PushBullet(@NotNull String channelTag, @NotNull String title, @NotNull String body) {
this.channelTag = channelTag;
this.title = title;
this.body = body;
@@ -134,19 +141,19 @@ public final class PushBulletNotificationAgent extends AbstractNotificationAgent
}
@JsonProperty("channel_tag")
public String getChannelTag() {
public @NotNull String getChannelTag() {
return channelTag;
}
public String getType() {
public @NotNull String getType() {
return type;
}
public String getTitle() {
public @NotNull String getTitle() {
return title;
}
public String getBody() {
public @NotNull String getBody() {
return body;
}
}
@@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.PushOverProperties;
import com.jasonhhouse.gaps.service.FileIoService;
import com.jasonhhouse.gaps.service.IO;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.HttpUrl;
@@ -25,7 +26,6 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,13 +34,15 @@ import static com.jasonhhouse.gaps.notifications.NotificationStatus.SEND_MESSAGE
import static com.jasonhhouse.gaps.notifications.NotificationStatus.TIMEOUT;
public final class PushOverNotificationAgent extends AbstractNotificationAgent<PushOverProperties> {
@NotNull
private static final Logger LOGGER = LoggerFactory.getLogger(PushOverNotificationAgent.class);
@NotNull
private static final ObjectMapper objectMapper = new ObjectMapper();
@NotNull
private final OkHttpClient client;
public PushOverNotificationAgent(FileIoService fileIoService) {
super(fileIoService);
public PushOverNotificationAgent(@NotNull IO ioService) {
super(ioService);
client = new OkHttpClient.Builder()
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
@@ -50,17 +52,17 @@ public final class PushOverNotificationAgent extends AbstractNotificationAgent<P
}
@Override
public int getId() {
public @NotNull Integer getId() {
return 5;
}
@Override
public String getName() {
public @NotNull String getName() {
return "PushOver Notification Agent";
}
@Override
public boolean sendMessage(NotificationType notificationType, String level, String title, String message) {
public @NotNull Boolean sendMessage(@NotNull NotificationType notificationType, @NotNull String level, @NotNull String title, @NotNull String message) {
LOGGER.info(SEND_MESSAGE, level, title, message);
if (sendPrepMessage(notificationType)) {
@@ -107,24 +109,37 @@ public final class PushOverNotificationAgent extends AbstractNotificationAgent<P
}
}
@NotNull
@Override
public PushOverProperties getNotificationProperties() {
return fileIoService.readProperties().getPushOverProperties();
public @NotNull PushOverProperties getNotificationProperties() {
return ioService.readProperties().getPushOverProperties();
}
private static final class PushOver {
@NotNull
private final String token;
@NotNull
private final String user;
@NotNull
private final Integer priority;
@NotNull
private final String sound;
@NotNull
private final String title;
@NotNull
private final String message;
@NotNull
private final Integer retry;
@NotNull
private final Integer expire;
public PushOver(String token, String user, Integer priority, String sound, String title, String message, Integer retry, Integer expire) {
public PushOver(@NotNull String token,
@NotNull String user,
@NotNull Integer priority,
@NotNull String sound,
@NotNull String title,
@NotNull String message,
@NotNull Integer retry,
@NotNull Integer expire) {
this.token = token;
this.user = user;
this.priority = priority;
@@ -135,35 +150,35 @@ public final class PushOverNotificationAgent extends AbstractNotificationAgent<P
this.expire = expire;
}
public String getToken() {
public @NotNull String getToken() {
return token;
}
public String getUser() {
public @NotNull String getUser() {
return user;
}
public Integer getPriority() {
public @NotNull Integer getPriority() {
return priority;
}
public String getSound() {
public @NotNull String getSound() {
return sound;
}
public String getTitle() {
public @NotNull String getTitle() {
return title;
}
public String getMessage() {
public @NotNull String getMessage() {
return message;
}
public Integer getRetry() {
public @NotNull Integer getRetry() {
return retry;
}
public Integer getExpire() {
public @NotNull Integer getExpire() {
return expire;
}
}
@@ -15,7 +15,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.SlackProperties;
import com.jasonhhouse.gaps.service.FileIoService;
import com.jasonhhouse.gaps.service.IO;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.Headers;
@@ -26,7 +26,6 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,12 +33,15 @@ import static com.jasonhhouse.gaps.notifications.NotificationStatus.TIMEOUT;
public final class SlackNotificationAgent extends AbstractNotificationAgent<SlackProperties> {
@NotNull
private static final Logger LOGGER = LoggerFactory.getLogger(SlackNotificationAgent.class);
@NotNull
private static final ObjectMapper objectMapper = new ObjectMapper();
@NotNull
private final OkHttpClient client;
public SlackNotificationAgent(FileIoService fileIoService) {
super(fileIoService);
public SlackNotificationAgent(@NotNull IO ioService) {
super(ioService);
client = new OkHttpClient.Builder()
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
@@ -49,17 +51,17 @@ public final class SlackNotificationAgent extends AbstractNotificationAgent<Slac
}
@Override
public int getId() {
public @NotNull Integer getId() {
return 2;
}
@Override
public String getName() {
public @NotNull String getName() {
return "Slack Notification Agent";
}
@Override
public boolean sendMessage(NotificationType notificationType, String level, String title, String message) {
public @NotNull Boolean sendMessage(@NotNull NotificationType notificationType, @NotNull String level, @NotNull String title, @NotNull String message) {
LOGGER.info("sendMessage( {}, {}, {} )", level, title, message);
if (sendPrepMessage(notificationType)) {
@@ -106,58 +108,62 @@ public final class SlackNotificationAgent extends AbstractNotificationAgent<Slac
}
}
@NotNull
@Override
public SlackProperties getNotificationProperties() {
return fileIoService.readProperties().getSlackProperties();
public @NotNull SlackProperties getNotificationProperties() {
return ioService.readProperties().getSlackProperties();
}
private static final class Slack {
@NotNull
private final Block[] blocks;
private Slack(String message) {
private Slack(@NotNull String message) {
blocks = new Block[1];
blocks[0] = new SlackNotificationAgent.Block(new Text(message));
}
public Block[] getBlocks() {
public @NotNull Block[] getBlocks() {
return blocks;
}
}
private static final class Block {
@NotNull
private final String type;
@NotNull
private final Text text;
private Block(Text text) {
private Block(@NotNull Text text) {
this.type = "section";
this.text = text;
}
public String getType() {
public @NotNull String getType() {
return type;
}
public Text getText() {
public @NotNull Text getText() {
return text;
}
}
private static final class Text {
@NotNull
private final String type;
@NotNull
private final String value;
private Text(String value) {
private Text(@NotNull String value) {
this.type = "mrkdwn";
this.value = value;
}
public String getType() {
public @NotNull String getType() {
return type;
}
@JsonProperty("text")
public String getValue() {
public @NotNull String getValue() {
return value;
}
}
@@ -14,7 +14,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.properties.TelegramProperties;
import com.jasonhhouse.gaps.service.FileIoService;
import com.jasonhhouse.gaps.service.IO;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.HttpUrl;
@@ -32,13 +32,15 @@ import static com.jasonhhouse.gaps.notifications.NotificationStatus.SEND_MESSAGE
import static com.jasonhhouse.gaps.notifications.NotificationStatus.TIMEOUT;
public final class TelegramNotificationAgent extends AbstractNotificationAgent<TelegramProperties> {
@NotNull
private static final Logger LOGGER = LoggerFactory.getLogger(TelegramNotificationAgent.class);
@NotNull
private static final ObjectMapper objectMapper = new ObjectMapper();
@NotNull
private final OkHttpClient client;
public TelegramNotificationAgent(FileIoService fileIoService) {
super(fileIoService);
public TelegramNotificationAgent(@NotNull IO ioService) {
super(ioService);
client = new OkHttpClient.Builder()
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
@@ -48,17 +50,17 @@ public final class TelegramNotificationAgent extends AbstractNotificationAgent<T
}
@Override
public int getId() {
public @NotNull Integer getId() {
return 0;
}
@Override
public String getName() {
public @NotNull String getName() {
return "Telegram Notification Agent";
}
@Override
public boolean sendMessage(NotificationType notificationType, String level, String title, String message) {
public @NotNull Boolean sendMessage(@NotNull NotificationType notificationType, @NotNull String level, @NotNull String title, @NotNull String message) {
LOGGER.info(SEND_MESSAGE, level, title, message);
if (sendPrepMessage(notificationType)) {
@@ -105,34 +107,36 @@ public final class TelegramNotificationAgent extends AbstractNotificationAgent<T
}
}
@NotNull
@Override
public TelegramProperties getNotificationProperties() {
return fileIoService.readProperties().getTelegramProperties();
public @NotNull TelegramProperties getNotificationProperties() {
return ioService.readProperties().getTelegramProperties();
}
public static final class Telegram {
@NotNull
private final String chatId;
@NotNull
private final String text;
@NotNull
private final String parseMode;
public Telegram(String chatId, String text, String parseMode) {
public Telegram(@NotNull String chatId, @NotNull String text, @NotNull String parseMode) {
this.chatId = chatId;
this.text = text;
this.parseMode = parseMode;
}
@JsonProperty("chat_id")
public String getChatId() {
public @NotNull String getChatId() {
return chatId;
}
public String getText() {
public @NotNull String getText() {
return text;
}
@JsonProperty("parse_mode")
public String getParseMode() {
public @NotNull String getParseMode() {
return parseMode;
}
}
@@ -2,28 +2,29 @@ package com.jasonhhouse.gaps.service;
import com.jasonhhouse.gaps.PlexServer;
import com.jasonhhouse.plex.libs.PlexLibrary;
import org.jetbrains.annotations.NotNull;
public interface Notification {
void plexServerConnectFailed(PlexServer plexServer, String error);
@NotNull Boolean plexServerConnectFailed(@NotNull PlexServer plexServer, @NotNull String error);
void plexServerConnectSuccessful(PlexServer plexServer);
@NotNull Boolean plexServerConnectSuccessful(@NotNull PlexServer plexServer);
void plexLibraryScanFailed(PlexServer plexServer, PlexLibrary plexLibrary, String error);
@NotNull Boolean plexLibraryScanFailed(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary, @NotNull String error);
void plexLibraryScanSuccessful(PlexServer plexServer, PlexLibrary plexLibrary);
@NotNull Boolean plexLibraryScanSuccessful(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary);
void tmdbConnectionFailed(String error);
@NotNull Boolean tmdbConnectionFailed(@NotNull String error);
void tmdbConnectionSuccessful();
@NotNull Boolean tmdbConnectionSuccessful();
void recommendedMoviesSearchStarted(PlexServer plexServer, PlexLibrary plexLibrary);
@NotNull Boolean recommendedMoviesSearchStarted(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary);
void recommendedMoviesSearchFailed(PlexServer plexServer, PlexLibrary plexLibrary, String error);
@NotNull Boolean recommendedMoviesSearchFailed(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary,@NotNull String error);
void recommendedMoviesSearchFinished(PlexServer plexServer, PlexLibrary plexLibrary);
@NotNull Boolean recommendedMoviesSearchFinished(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary);
boolean test();
@NotNull Boolean test();
boolean test(int id) throws IllegalArgumentException, IllegalAccessException;
@NotNull Boolean test(@NotNull Integer id) throws IllegalArgumentException, IllegalAccessException;
}
@@ -1,11 +1,12 @@
/*
* Copyright 2019 Jason H House
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.jasonhhouse.gaps.service;
@@ -15,6 +16,7 @@ import com.jasonhhouse.gaps.notifications.NotificationAgent;
import com.jasonhhouse.gaps.properties.NotificationProperties;
import com.jasonhhouse.plex.libs.PlexLibrary;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -31,145 +33,197 @@ public class NotificationService implements Notification {
}
@Override
public void plexServerConnectFailed(PlexServer plexServer, String error) {
public @NotNull Boolean plexServerConnectFailed(@NotNull PlexServer plexServer, @NotNull String error) {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.PLEX_SERVER_CONNECTION, "ERROR", "Gaps Search", String.format("Connection to Plex Server %s Failed. %s", plexServer.getFriendlyName(), error));
Boolean result = notificationAgent.sendMessage(NotificationType.PLEX_SERVER_CONNECTION, "ERROR", "Gaps Search", String.format("Connection to Plex Server %s Failed. %s", plexServer.getFriendlyName(), error));
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when plex server connection failed to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public void plexServerConnectSuccessful(PlexServer plexServer) {
public @NotNull Boolean plexServerConnectSuccessful(@NotNull PlexServer plexServer) {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.PLEX_SERVER_CONNECTION, "INFO", "Gaps Search", String.format("Connection to Plex Server %s Successful", plexServer.getFriendlyName()));
Boolean result = notificationAgent.sendMessage(NotificationType.PLEX_SERVER_CONNECTION, "INFO", "Gaps Search", String.format("Connection to Plex Server %s Successful", plexServer.getFriendlyName()));
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when plex server connection successful to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public void plexLibraryScanFailed(PlexServer plexServer, PlexLibrary plexLibrary, String error) {
public @NotNull Boolean plexLibraryScanFailed(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary, @NotNull String error) {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.PLEX_METADATA_UPDATE, "INFO", "Gaps Search", String.format("Scanning Plex Server %s in %s Library Failed. %s", plexServer.getFriendlyName(), plexLibrary.getTitle(), error));
Boolean result = notificationAgent.sendMessage(NotificationType.PLEX_METADATA_UPDATE, "INFO", "Gaps Search", String.format("Scanning Plex Server %s in %s Library Failed. %s", plexServer.getFriendlyName(), plexLibrary.getTitle(), error));
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when plex library scan failed to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public void plexLibraryScanSuccessful(PlexServer plexServer, PlexLibrary plexLibrary) {
public @NotNull Boolean plexLibraryScanSuccessful(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary) {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.PLEX_METADATA_UPDATE, "INFO", "Gaps Search", String.format("Scanning Plex Server %s in %s Library Successful", plexServer.getFriendlyName(), plexLibrary.getTitle()));
Boolean result = notificationAgent.sendMessage(NotificationType.PLEX_METADATA_UPDATE, "INFO", "Gaps Search", String.format("Scanning Plex Server %s in %s Library Successful", plexServer.getFriendlyName(), plexLibrary.getTitle()));
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when plex library scan succeeded to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public void tmdbConnectionFailed(String error) {
public @NotNull Boolean tmdbConnectionFailed(@NotNull String error) {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.TMDB_API_CONNECTION, "INFO", "Gaps Search", String.format("TMDB Connection Failed. %s", error));
Boolean result = notificationAgent.sendMessage(NotificationType.TMDB_API_CONNECTION, "INFO", "Gaps Search", String.format("TMDB Connection Failed. %s", error));
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when TMDB connection test failed to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public void tmdbConnectionSuccessful() {
public @NotNull Boolean tmdbConnectionSuccessful() {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.TMDB_API_CONNECTION, "INFO", "Gaps Search", "TMDB Connection Successful");
Boolean result = notificationAgent.sendMessage(NotificationType.TMDB_API_CONNECTION, "INFO", "Gaps Search", "TMDB Connection Successful");
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when TMDB connection test succeeded to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public void recommendedMoviesSearchStarted(PlexServer plexServer, PlexLibrary plexLibrary) {
public @NotNull Boolean recommendedMoviesSearchStarted(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary) {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "INFO", "Gaps Search", String.format("Scanning Plex Server %s on Library %s Started", plexServer.getFriendlyName(), plexLibrary.getTitle()));
Boolean result = notificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "INFO", "Gaps Search", String.format("Scanning Plex Server %s on Library %s Started", plexServer.getFriendlyName(), plexLibrary.getTitle()));
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when recommending movies started to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public void recommendedMoviesSearchFailed(PlexServer plexServer, PlexLibrary plexLibrary, String error) {
public @NotNull Boolean recommendedMoviesSearchFailed(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary, @NotNull String error) {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "INFO", "Gaps Search", String.format("Scanning Plex Server %s on Library %s Failed %s", plexServer.getFriendlyName(), plexLibrary.getTitle(), error));
Boolean result = notificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "INFO", "Gaps Search", String.format("Scanning Plex Server %s on Library %s Failed %s", plexServer.getFriendlyName(), plexLibrary.getTitle(), error));
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when recommending movies failed to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public void recommendedMoviesSearchFinished(PlexServer plexServer, PlexLibrary plexLibrary) {
public @NotNull Boolean recommendedMoviesSearchFinished(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary) {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.isEnabled()) {
try {
notificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "INFO", "Gaps Search", String.format("Scanning Plex Server %s on Library %s Successfully Finished", plexServer.getFriendlyName(), plexLibrary.getTitle()));
Boolean result = notificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "INFO", "Gaps Search", String.format("Scanning Plex Server %s on Library %s Successfully Finished", plexServer.getFriendlyName(), plexLibrary.getTitle()));
if (!result) {
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send message when recommending movies finished to %s", notificationAgent.getName()), e);
sentAllNotifications = false;
}
}
}
return sentAllNotifications;
}
@Override
public boolean test() {
boolean passedTest = true;
public @NotNull Boolean test() {
boolean sentAllNotifications = true;
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
try {
boolean result = notificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
Boolean result = notificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
if (!result) {
passedTest = false;
sentAllNotifications = false;
}
} catch (Exception e) {
LOGGER.error(String.format("Failed to send test all message to %s", notificationAgent.getName()), e);
return false;
sentAllNotifications = false;
}
}
return passedTest;
return sentAllNotifications;
}
@Override
public boolean test(int id) throws IllegalArgumentException {
public @NotNull Boolean test(@NotNull Integer id) throws IllegalArgumentException {
for (NotificationAgent<? extends NotificationProperties> notificationAgent : notificationAgents) {
if (notificationAgent.getId() == id) {
if (notificationAgent.getId().equals(id)) {
try {
return notificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
} catch (Exception e) {
@@ -418,10 +418,10 @@
<div id="{{machineIdentifier}}" class="col-lg-4">
<div class="top-margin">
<div class="card border-secondary mb-3" style="max-width: 20rem;">
<div class="card-header">{{friendlyName}}</div>
<div data-cy="{{friendlyName}}" class="card-header">{{friendlyName}}</div>
<ul class="list-group list-group-flush">
{{#each plexLibraries}}
<li class="list-group-item">{{title}}</li>
<li data-cy="{{title}}" class="list-group-item">{{title}}</li>
{{/each}}
</ul>
<div class="card-body">
@@ -94,6 +94,7 @@
<a class="dropdown-item"
data-ol-has-click-handler=""
href="javascript:void(0)"
th:data-cy="*{plexLibrary.title}"
th:data-key="*{plexLibrary.key}"
th:data-machineIdentifier="*{instance.value.machineIdentifier}"
th:each="plexLibrary : *{instance.value.plexLibraries}"
@@ -120,7 +121,7 @@
<div class="card-body">
<h5 class="card-title">Your movies are really missing</h5>
<p class="card-text">You need to run Gaps at least once to have found the missing movies.</p>
<a class="btn btn-primary" href="javascript:void(0)" onclick="searchForMovies()">Search</a>
<a data-cy="searchForMovies" class="btn btn-primary" href="javascript:void(0)" onclick="searchForMovies()">Search</a>
</div>
</div>
</div>
@@ -160,7 +161,7 @@
<div class="card">
<div class="row no-gutters">
<div class="col-12 col-md-auto">
<img style="height: auto; width: 225px; display: block;"
<img data-cy="{{imdbId}}" style="height: auto; width: 225px; display: block;"
src="http://{{address}}:{{port}}{{posterUrl}}/?X-Plex-Token={{plexToken}}"
class="card-img" alt="Plex Poster">
</div>
@@ -93,6 +93,7 @@
<a class="dropdown-item"
data-ol-has-click-handler=""
href="javascript:void(0)"
th:data-cy="*{plexLibrary.title}"
th:data-key="*{plexLibrary.key}"
th:data-machineIdentifier="*{instance.value.machineIdentifier}"
th:each="plexLibrary : *{instance.value.plexLibraries}"
@@ -108,7 +109,7 @@
<div class="card-body">
<h5 class="card-title">Your movies are really missing</h5>
<p class="card-text">You need to run Gaps at least once to have found the missing movies.</p>
<a class="btn btn-primary" href="javascript:void(0)" onclick="searchForMovies()">Search</a>
<a data-cy="searchForMovies" class="btn btn-primary" href="javascript:void(0)" onclick="searchForMovies()">Search</a>
</div>
</div>
</div>
@@ -171,6 +172,7 @@
<div class="row no-gutters">
<div class="col-12 col-md-auto">
<img style="height: auto; width: 225px; display: block;"
data-cy="{{imdbId}}"
src="{{posterUrl}}"
class="card-img" alt="Plex Poster">
</div>
@@ -0,0 +1,43 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.service.FakeIoService;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class DiscordNotificationAgentTest {
@NotNull
private DiscordNotificationAgent discordNotificationAgent;
@BeforeEach
void setUp() {
discordNotificationAgent = new DiscordNotificationAgent(new FakeIoService());
}
@Test
void sendMessage() {
Boolean sentSuccessfully = discordNotificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
assertTrue(sentSuccessfully, "Should have sent test discord message");
}
@Test
void failToMessage() {
Boolean sentUnsuccessfully = discordNotificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "DEBUG", "Gaps Test", "Test Successful");
assertFalse(sentUnsuccessfully, "Should have not sent test discord message");
}
}
@@ -0,0 +1,44 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.service.FakeIoService;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class EmailNotificationAgentTest {
@NotNull
private EmailNotificationAgent emailNotificationAgent;
@BeforeEach
void setUp() {
emailNotificationAgent = new EmailNotificationAgent(new FakeIoService());
}
@Test
void sendMessage() {
Boolean sentSuccessfully = emailNotificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
assertTrue(sentSuccessfully, "Should have sent test email message");
}
@Test
void failToMessage() {
Boolean sentUnsuccessfully = emailNotificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "DEBUG", "Gaps Test", "Test Successful");
assertFalse(sentUnsuccessfully, "Should have not sent test email message");
}
}
@@ -0,0 +1,43 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.service.FakeIoService;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class GotifyNotificationAgentTest {
@NotNull
private GotifyNotificationAgent gotifyNotificationAgent;
@BeforeEach
void setUp() {
gotifyNotificationAgent = new GotifyNotificationAgent(new FakeIoService());
}
@Test
void sendMessage() {
Boolean sentSuccessfully = gotifyNotificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
assertTrue(sentSuccessfully, "Should have sent test gotify message");
}
@Test
void failToMessage() {
Boolean sentUnsuccessfully = gotifyNotificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "DEBUG", "Gaps Test", "Test Successful");
assertFalse(sentUnsuccessfully, "Should have not sent test gotify message");
}
}
@@ -0,0 +1,43 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.service.FakeIoService;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PushBulletNotificationAgentTest {
@NotNull
private PushBulletNotificationAgent pushBulletNotificationAgent;
@BeforeEach
void setUp() {
pushBulletNotificationAgent = new PushBulletNotificationAgent(new FakeIoService());
}
@Test
void sendMessage() {
Boolean sentSuccessfully = pushBulletNotificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
assertTrue(sentSuccessfully, "Should have sent test pushBullet message");
}
@Test
void failToMessage() {
Boolean sentUnsuccessfully = pushBulletNotificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "DEBUG", "Gaps Test", "Test Successful");
assertFalse(sentUnsuccessfully, "Should have not sent pushBullet email message");
}
}
@@ -0,0 +1,43 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.service.FakeIoService;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class PushOverNotificationAgentTest {
@NotNull
private PushOverNotificationAgent pushOverNotificationAgent;
@BeforeEach
void setUp() {
pushOverNotificationAgent = new PushOverNotificationAgent(new FakeIoService());
}
@Test
void sendMessage() {
Boolean sentSuccessfully = pushOverNotificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
assertTrue(sentSuccessfully, "Should have sent test pushOver message");
}
@Test
void failToMessage() {
Boolean sentUnsuccessfully = pushOverNotificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "DEBUG", "Gaps Test", "Test Successful");
assertFalse(sentUnsuccessfully, "Should have not sent pushOver email message");
}
}
@@ -0,0 +1,43 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.service.FakeIoService;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class SlackNotificationAgentTest {
@NotNull
private SlackNotificationAgent slackNotificationAgent;
@BeforeEach
void setUp() {
slackNotificationAgent = new SlackNotificationAgent(new FakeIoService());
}
@Test
void sendMessage() {
Boolean sentSuccessfully = slackNotificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
assertTrue(sentSuccessfully, "Should have sent test slack message");
}
@Test
void failToMessage() {
Boolean sentUnsuccessfully = slackNotificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "DEBUG", "Gaps Test", "Test Successful");
assertFalse(sentUnsuccessfully, "Should have not sent slack email message");
}
}
@@ -0,0 +1,45 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.notifications;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.service.FakeIoService;
import com.jasonhhouse.gaps.service.IO;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class TelegramNotificationAgentTest {
@NotNull
private TelegramNotificationAgent telegramNotificationAgent;
@BeforeEach
void setUp() {
telegramNotificationAgent = new TelegramNotificationAgent(new FakeIoService());
}
@Test
void sendMessage() {
Boolean sentSuccessfully = telegramNotificationAgent.sendMessage(NotificationType.TEST, "DEBUG", "Gaps Test", "Test Successful");
assertTrue(sentSuccessfully, "Should have sent test telegram message");
}
@Test
void failToMessage() {
Boolean sentUnsuccessfully = telegramNotificationAgent.sendMessage(NotificationType.GAPS_MISSING_COLLECTIONS, "DEBUG", "Gaps Test", "Test Successful");
assertFalse(sentUnsuccessfully, "Should have not sent telegram email message");
}
}
@@ -0,0 +1,150 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.service;
import com.jasonhhouse.gaps.BasicMovie;
import com.jasonhhouse.gaps.NotificationType;
import com.jasonhhouse.gaps.Payload;
import com.jasonhhouse.gaps.PlexServer;
import com.jasonhhouse.gaps.properties.DiscordProperties;
import com.jasonhhouse.gaps.properties.EmailProperties;
import com.jasonhhouse.gaps.properties.GotifyProperties;
import com.jasonhhouse.gaps.properties.PlexProperties;
import com.jasonhhouse.gaps.properties.PushBulletProperties;
import com.jasonhhouse.gaps.properties.PushOverProperties;
import com.jasonhhouse.gaps.properties.SlackProperties;
import com.jasonhhouse.gaps.properties.TelegramProperties;
import java.io.File;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
public class FakeIoService implements IO {
@Override
public @NotNull List<BasicMovie> readRecommendedMovies(@NotNull String machineIdentifier, @NotNull Integer key) {
return null;
}
@Override
public @NotNull Boolean doesRssFileExist(@NotNull String machineIdentifier, @NotNull Integer key) {
return null;
}
@Override
public @NotNull String getRssFile(String machineIdentifier, @NotNull Integer key) {
return null;
}
@Override
public void writeRssFile(@NotNull String machineIdentifier, @NotNull Integer key, @NotNull Set<BasicMovie> recommended) {
}
@Override
public void writeRecommendedToFile(@NotNull Set<BasicMovie> recommended, @NotNull String machineIdentifier, @NotNull Integer key) {
}
@Override
public void writeOwnedMoviesToFile(@NotNull List<BasicMovie> ownedBasicMovies, @NotNull String machineIdentifier, @NotNull Integer key) {
}
@Override
public @NotNull List<BasicMovie> readOwnedMovies(@NotNull String machineIdentifier, @NotNull Integer key) {
return null;
}
@Override
public void writeMovieIdsToFile(@NotNull Set<BasicMovie> everyBasicMovie) {
}
@Override
public void writeMovieIdsToFile(@NotNull Set<BasicMovie> everyBasicMovie, @NotNull File file) {
}
@Override
public @NotNull Set<BasicMovie> readMovieIdsFromFile() {
return null;
}
@Override
public void writeProperties(@NotNull PlexProperties plexProperties) {
}
@Override
public @NotNull PlexProperties readProperties() {
List<NotificationType> notificationTypes = new ArrayList<>();
notificationTypes.add(NotificationType.TEST);
notificationTypes.add(NotificationType.PLEX_SERVER_CONNECTION);
String telegramArg1 = new String(Base64.getDecoder().decode("MTMwMjEzOTExOTpBQUV1cGh0RXVvcFhhVHBpdGlHbFdDWS0zbDMzU0JrUGUybw"));
String telegramArg2 = new String(Base64.getDecoder().decode("MTA0MTA4MTMxNw=="));
TelegramProperties telegramProperties = new TelegramProperties(true, notificationTypes, telegramArg1, telegramArg2);
String slackArg1 = new String(Base64.getDecoder().decode("aHR0cHM6Ly9ob29rcy5zbGFjay5jb20vc2VydmljZXMvVDAxN1hSMEJNUlYvQjAxOEs0TkE3NjAvemsxcVVWMno1N0w4c3lqQ0ExUU8xRFFE"));
SlackProperties slackProperties = new SlackProperties(true, notificationTypes, slackArg1);
String pushOverArg1 = new String(Base64.getDecoder().decode("YWM1ZjJya2JwejEyMnBqenNlMnBlbmJkdmYxZ2dh"));
String pushOverArg2 = new String(Base64.getDecoder().decode("dTdiemZkZW5kdmRqbnM1eXRrMmV3YjIxZDduaWJ5"));
Integer priority = 1;
String sound = "spacealarm";
Integer retry = 1;
Integer expire = 2;
PushOverProperties pushOverProperties = new PushOverProperties(true, notificationTypes, pushOverArg1, pushOverArg2, priority, sound, retry, expire);
String pushBulletArg1 = new String(Base64.getDecoder().decode("Z2Fwcw=="));
String pushBulletArg2 = new String(Base64.getDecoder().decode("by5pdjBXbXRuTFdJM3hmaFRTTmh1dVF2Tm1vdlVGSHN6dA=="));
PushBulletProperties pushBulletProperties = new PushBulletProperties(true, notificationTypes, pushBulletArg1, pushBulletArg2);
String gotifyArg1 = new String(Base64.getDecoder().decode("aHR0cDovLzE5Mi4xNjguMS44OjgwNzA="));
String gotifyArg2 = new String(Base64.getDecoder().decode("QVJkbS55SHRQUTlhaW5i"));
GotifyProperties gotifyProperties = new GotifyProperties(true, notificationTypes, gotifyArg1, gotifyArg2);
String emailArg1 = new String(Base64.getDecoder().decode("amg1OTc1"));
String emailArg2 = new String(Base64.getDecoder().decode("aWJnYnR3aXdyd2xvZWNucA=="));
String emailArg3 = new String(Base64.getDecoder().decode("amg1OTc1QGdtYWlsLmNvbQ=="));
String emailArg4 = new String(Base64.getDecoder().decode("amg1OTc1QGdtYWlsLmNvbQ=="));
String emailArg5 = new String(Base64.getDecoder().decode("c210cC5nbWFpbC5jb20="));
Integer emailArg6 = Integer.valueOf(new String(Base64.getDecoder().decode("NTg3")));
String emailArg7 = new String(Base64.getDecoder().decode("c210cA=="));
String emailArg8 = new String(Base64.getDecoder().decode("amg1OTc1"));
EmailProperties emailProperties = new EmailProperties(true, notificationTypes, emailArg1, emailArg2, emailArg3, emailArg4, emailArg5, emailArg6, emailArg7, emailArg8, true);
String discordArg1 = new String(Base64.getDecoder().decode("aHR0cHM6Ly9kaXNjb3JkYXBwLmNvbS9hcGkvd2ViaG9va3MvNzU2MzExMTkwOTU0NTczOTU2L0Uwa25VRF91akxIQU5oZTA3MGEwYW9PMUNnMGRNQUV4Z1FBbEZGTS1GZUgwNnl3VGExLU42c2ZhREpQSC1lM2dDVEZz"));
DiscordProperties discordProperties = new DiscordProperties(true, notificationTypes, discordArg1);
PlexServer plexServer = new PlexServer();
//plexServer.setAddress();
PlexProperties plexProperties = new PlexProperties();
plexProperties.setTelegramProperties(telegramProperties);
plexProperties.setSlackProperties(slackProperties);
plexProperties.setPushOverProperties(pushOverProperties);
plexProperties.setPushBulletProperties(pushBulletProperties);
plexProperties.setGotifyProperties(gotifyProperties);
plexProperties.setEmailProperties(emailProperties);
plexProperties.setDiscordProperties(discordProperties);
return plexProperties;
}
@Override
public @NotNull Payload nuke() {
return null;
}
}
@@ -0,0 +1,66 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
package com.jasonhhouse.gaps.service;
import com.jasonhhouse.gaps.PlexServer;
import com.jasonhhouse.gaps.notifications.DiscordNotificationAgent;
import com.jasonhhouse.gaps.notifications.EmailNotificationAgent;
import com.jasonhhouse.gaps.notifications.GotifyNotificationAgent;
import com.jasonhhouse.gaps.notifications.NotificationAgent;
import com.jasonhhouse.gaps.notifications.PushBulletNotificationAgent;
import com.jasonhhouse.gaps.notifications.PushOverNotificationAgent;
import com.jasonhhouse.gaps.notifications.SlackNotificationAgent;
import com.jasonhhouse.gaps.notifications.TelegramNotificationAgent;
import com.jasonhhouse.gaps.properties.NotificationProperties;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
class NotificationServiceTest {
private NotificationService notificationService;
@BeforeEach
void setUp() {
List<NotificationAgent<? extends NotificationProperties>> notificationTypeList = new ArrayList<>();
notificationTypeList.add(new DiscordNotificationAgent(new FakeIoService()));
notificationTypeList.add(new EmailNotificationAgent(new FakeIoService()));
notificationTypeList.add(new GotifyNotificationAgent(new FakeIoService()));
notificationTypeList.add(new PushBulletNotificationAgent(new FakeIoService()));
notificationTypeList.add(new PushOverNotificationAgent(new FakeIoService()));
notificationTypeList.add(new SlackNotificationAgent(new FakeIoService()));
notificationTypeList.add(new TelegramNotificationAgent(new FakeIoService()));
notificationService = new NotificationService(notificationTypeList);
}
@Test
public void plexServerConnectFailed() {
PlexServer plexServer = new PlexServer();
plexServer.setFriendlyName("Friendly Name");
String error = "";
Boolean result = notificationService.plexServerConnectFailed(plexServer, error);
assertTrue(result, "Should have sent plex server connect failed message");
}
@Test
public void tmdbConnectionFailed() {
Boolean result = notificationService.tmdbConnectionFailed("");
assertFalse(result, "Should have failed to send plex server connect failed");
}
}
+179
View File
@@ -0,0 +1,179 @@
{
"plexServers": [
{
"plexLibraries": [
{
"location": {
"value": "",
"id": 4,
"path": "/data/gaps/Best Movies"
},
"allowSync": 1,
"art": "/:/resources/movie-fanart.jpg",
"composite": "/library/sections/4/composite/1602040076",
"filters": 1,
"refreshing": 0,
"thumb": "/:/resources/movie.png",
"key": 4,
"type": "movie",
"title": "Best Movies",
"agent": "com.plexapp.agents.imdb",
"scanner": "Plex Movie Scanner",
"language": "en",
"uuid": "4f7abfee-824d-485b-906a-27c917e222d5",
"updatedAt": 1601899630,
"createdAt": 1601864973,
"scannedAt": 1602040076,
"content": 1,
"directory": 1,
"contentChangedAt": -30488,
"hidden": 0
},
{
"location": {
"value": "",
"id": 1,
"path": "/data/Movies"
},
"allowSync": 1,
"art": "/:/resources/movie-fanart.jpg",
"composite": "/library/sections/1/composite/1602040754",
"filters": 1,
"refreshing": 0,
"thumb": "/:/resources/movie.png",
"key": 1,
"type": "movie",
"title": "Movies",
"agent": "com.plexapp.agents.themoviedb",
"scanner": "Plex Movie Scanner",
"language": "en",
"uuid": "07c0a834-dbd1-43eb-b647-0099474bfd00",
"updatedAt": 1601969240,
"createdAt": 1584962634,
"scannedAt": 1602040754,
"content": 1,
"directory": 1,
"contentChangedAt": -20533,
"hidden": 0
},
{
"location": {
"value": "",
"id": 6,
"path": "/data/gaps/Movies"
},
"allowSync": 1,
"art": "/:/resources/movie-fanart.jpg",
"composite": "/library/sections/6/composite/1602040754",
"filters": 1,
"refreshing": 0,
"thumb": "/:/resources/movie.png",
"key": 6,
"type": "movie",
"title": "Movies with new Metadata",
"agent": "tv.plex.agents.movie",
"scanner": "Plex Movie",
"language": "en-US",
"uuid": "f6763a83-03d8-4c88-af3f-15b2f45a37ad",
"updatedAt": 1601899889,
"createdAt": 1601865143,
"scannedAt": 1602040754,
"content": 1,
"directory": 1,
"contentChangedAt": -26463,
"hidden": 0
},
{
"location": {
"value": "",
"id": 5,
"path": "/data/gaps/Movies2"
},
"allowSync": 1,
"art": "/:/resources/movie-fanart.jpg",
"composite": "/library/sections/5/composite/1602040763",
"filters": 1,
"refreshing": 0,
"thumb": "/:/resources/movie.png",
"key": 5,
"type": "movie",
"title": "Saw",
"agent": "com.plexapp.agents.imdb",
"scanner": "Plex Movie Scanner",
"language": "en",
"uuid": "236126a3-a526-470c-b59e-9c83efb03b05",
"updatedAt": 1601900204,
"createdAt": 1601865059,
"scannedAt": 1602040763,
"content": 1,
"directory": 1,
"contentChangedAt": -29899,
"hidden": 0
}
],
"friendlyName": "Joker",
"machineIdentifier": "c51c432ae94e316d52570550f915ecbcd71bede8",
"plexToken": "mQw4uawxTyYEmqNUrvBz",
"address": "192.168.1.8",
"port": 32400
}
],
"telegramProperties": {
"enabled": false,
"notificationTypes": [],
"botId": "",
"chatId": ""
},
"pushBulletProperties": {
"enabled": false,
"notificationTypes": [],
"channel_tag": "",
"accessToken": ""
},
"emailProperties": {
"enabled": false,
"notificationTypes": [],
"username": "",
"password": "",
"mailTo": "",
"mailFrom": "",
"mailServer": "",
"mailPort": 0,
"mailTransportProtocol": "",
"mailSmtpAuth": "",
"mailSmtpTlsEnabled": false
},
"gotifyProperties": {
"enabled": false,
"notificationTypes": [],
"address": "",
"token": ""
},
"slackProperties": {
"enabled": false,
"notificationTypes": [],
"webHookUrl": ""
},
"pushOverProperties": {
"enabled": false,
"notificationTypes": [],
"token": "",
"user": "",
"priority": 0,
"sound": "",
"retry": 0,
"expire": 0
},
"discordProperties": {
"enabled": false,
"notificationTypes": [],
"webHookUrl": ""
},
"movieDbApiKey": "723b4c763114904392ca441909aa0375",
"password": "",
"schedule": {
"id": 2,
"message": "Weekly",
"enabled": true
}
}
File diff suppressed because one or more lines are too long
+384
View File
@@ -0,0 +1,384 @@
{
"code": 40,
"reason": "Plex's library movies found.",
"extras": [
{
"name": "Batman Return of the Caped Crusaders",
"year": 2016,
"posterUrl": "/library/metadata/48497/thumb/1601864977",
"imdbId": "",
"language": "en",
"overview": "Adam West and Burt Ward returns to their iconic roles of Batman and Robin. The film sees the superheroes going up against classic villains like The Joker, The Riddler, The Penguin and Catwoman, both in Gotham City… and in space.",
"moviesInCollection": [],
"ratingKey": 48497,
"key": "/library/metadata/48497",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Beauty and the Beast",
"year": 2017,
"posterUrl": "/library/metadata/48546/thumb/1601864994",
"imdbId": "",
"language": "en",
"overview": "A live-action adaptation of Disney's version of the classic tale of a cursed prince and a beautiful young woman who helps him break the spell.",
"moviesInCollection": [],
"ratingKey": 48546,
"key": "/library/metadata/48546",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Blade Runner 2049",
"year": 2017,
"posterUrl": "/library/metadata/48704/thumb/1601865018",
"imdbId": "",
"language": "en",
"overview": "Young Blade Runner K's discovery of a long-buried secret leads him to track down former Blade Runner Rick Deckard, who's been missing for thirty years.",
"moviesInCollection": [],
"ratingKey": 48704,
"key": "/library/metadata/48704",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Bill & Ted's Excellent Adventure",
"year": 1989,
"posterUrl": "/library/metadata/48653/thumb/1601865012",
"imdbId": "",
"language": "en",
"overview": "Two seemingly dumb teens set off on a quest to prepare the ultimate historical presentation with the help of a time machine.",
"moviesInCollection": [],
"ratingKey": 48653,
"key": "/library/metadata/48653",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Batman vs. Robin",
"year": 2015,
"posterUrl": "/library/metadata/48506/thumb/1601864980",
"imdbId": "",
"language": "en",
"overview": "Damian Wayne is having a hard time coping with his father's \"no killing\" rule. Meanwhile, Gotham is going through hell with threats such as the insane Dollmaker, and the secretive Court of Owls.",
"moviesInCollection": [],
"ratingKey": 48506,
"key": "/library/metadata/48506",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Batman Year One",
"year": 2011,
"posterUrl": "/library/metadata/48537/thumb/1601864987",
"imdbId": "",
"language": "en",
"overview": "Two men come to Gotham City: Bruce Wayne after years abroad feeding his lifelong obsession for justice and Jim Gordon after being too honest a cop with the wrong people elsewhere. After learning painful lessons about the city's corruption on its streets and police department respectively, this pair learn how to fight back their own way. With that, Gotham's evildoers from top to bottom are terrorized by the mysterious Batman and the equally heroic Gordon is assigned to catch him by comrades who both hate and fear him themselves. In the ensuing manhunt, both find much in common as the seeds of an unexpected friendship are laid with additional friends and rivals helping to start the legend.",
"moviesInCollection": [],
"ratingKey": 48537,
"key": "/library/metadata/48537",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Big Trouble in Little China",
"year": 1986,
"posterUrl": "/library/metadata/48603/thumb/1601865009",
"imdbId": "",
"language": "en",
"overview": "A rough-and-tumble trucker helps rescue his friend's fiancée from an ancient sorcerer in a supernatural battle beneath Chinatown.",
"moviesInCollection": [],
"ratingKey": 48603,
"key": "/library/metadata/48603",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Blazing Saddles",
"year": 1974,
"posterUrl": "/library/metadata/48718/thumb/1601865020",
"imdbId": "",
"language": "en",
"overview": "In order to ruin a western town, a corrupt politician appoints a black Sheriff, who promptly becomes his most formidable adversary.",
"moviesInCollection": [],
"ratingKey": 48718,
"key": "/library/metadata/48718",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Batman vs. Two-Face",
"year": 2017,
"posterUrl": "/library/metadata/48536/thumb/1601864987",
"imdbId": "",
"language": "en",
"overview": "Former Gotham City District Attorney Harvey Dent, one side of his face scarred by acid, goes on a crime spree based on the number '2'. All of his actions are decided by the flip of a defaced, two-headed silver dollar.",
"moviesInCollection": [],
"ratingKey": 48536,
"key": "/library/metadata/48536",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Beauty and the Beast",
"year": 1991,
"posterUrl": "/library/metadata/48544/thumb/1601864989",
"imdbId": "",
"language": "en",
"overview": "Follow the adventures of Belle, a bright young woman who finds herself in the castle of a prince who's been turned into a mysterious beast. With the help of the castle's enchanted staff, Belle soon learns the most important lesson of all -- that true beauty comes from within.",
"moviesInCollection": [],
"ratingKey": 48544,
"key": "/library/metadata/48544",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Blade Runner",
"year": 1982,
"posterUrl": "/library/metadata/48696/thumb/1601865015",
"imdbId": "",
"language": "en",
"overview": "A blade runner must pursue and terminate four replicants who stole a ship in space, and have returned to Earth to find their creator.",
"moviesInCollection": [],
"ratingKey": 48696,
"key": "/library/metadata/48696",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Bedazzled",
"year": 1967,
"posterUrl": "/library/metadata/48547/thumb/1601864996",
"imdbId": "",
"language": "en",
"overview": "Stanley is infatuated with Margaret, the statuesque waitress who works with him. He meets George Spiggott AKA the devil and sells his soul for 7 wishes, which Stanley uses to try and make Margaret his own first as an intellectual, then as a rock star, then as a wealthy industrialist. As each fails, he becomes more aware of how empty his life had been and how much more he has to live for.",
"moviesInCollection": [],
"ratingKey": 48547,
"key": "/library/metadata/48547",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Ben-Hur",
"year": 2016,
"posterUrl": "/library/metadata/48601/thumb/1601865008",
"imdbId": "",
"language": "en",
"overview": "Judah Ben-Hur, a prince falsely accused of treason by his adopted brother, an officer in the Roman army, returns to his homeland after years at sea to seek revenge, but finds redemption.",
"moviesInCollection": [],
"ratingKey": 48601,
"key": "/library/metadata/48601",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Bill & Ted's Bogus Journey",
"year": 1991,
"posterUrl": "/library/metadata/48651/thumb/1601865011",
"imdbId": "",
"language": "en",
"overview": "A tyrant from the future creates evil android doubles of Bill and Ted and sends them back to eliminate the originals.",
"moviesInCollection": [],
"ratingKey": 48651,
"key": "/library/metadata/48651",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Batman v Superman Dawn of Justice",
"year": 2016,
"posterUrl": "/library/metadata/48505/thumb/1601864979",
"imdbId": "",
"language": "en",
"overview": "Fearing the actions of a god-like Super Hero left unchecked, Gotham Citys own formidable, forceful vigilante takes on Metropoliss most revered, modern-day savior, while the world wrestles with what sort of hero it really needs. And with Batman and Superman at war with one another, a new threat quickly arises, putting mankind in greater danger than its ever known before.",
"moviesInCollection": [],
"ratingKey": 48505,
"key": "/library/metadata/48505",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Blade Trinity",
"year": 2004,
"posterUrl": "/library/metadata/48705/thumb/1601865017",
"imdbId": "",
"language": "en",
"overview": "Blade, now a wanted man by the FBI, must join forces with the Nightstalkers to face his most challenging enemy yet: Dracula.",
"moviesInCollection": [],
"ratingKey": 48705,
"key": "/library/metadata/48705",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Blade",
"year": 1998,
"posterUrl": "/library/metadata/48654/thumb/1601865012",
"imdbId": "",
"language": "en",
"overview": "A half-vampire, half-mortal man becomes a protector of the mortal race, while slaying evil vampires.",
"moviesInCollection": [],
"ratingKey": 48654,
"key": "/library/metadata/48654",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Blade II",
"year": 2002,
"posterUrl": "/library/metadata/48679/thumb/1601865013",
"imdbId": "",
"language": "en",
"overview": "Blade forms an uneasy alliance with the vampire council in order to combat the Reapers, who are feeding on vampires.",
"moviesInCollection": [],
"ratingKey": 48679,
"key": "/library/metadata/48679",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Beetlejuice",
"year": 1988,
"posterUrl": "/library/metadata/48589/thumb/1601864998",
"imdbId": "",
"language": "en",
"overview": "The spirits of a deceased couple are harassed by an unbearable family that has moved into their home, and hire a malicious spirit to drive them out.",
"moviesInCollection": [],
"ratingKey": 48589,
"key": "/library/metadata/48589",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Ben-Hur",
"year": 1959,
"posterUrl": "/library/metadata/48597/thumb/1601865004",
"imdbId": "",
"language": "en",
"overview": "After a Jewish prince is betrayed and sent into slavery by a Roman friend, he regains his freedom and comes back for revenge.",
"moviesInCollection": [],
"ratingKey": 48597,
"key": "/library/metadata/48597",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Batman The Dark Knight Returns, Part 2",
"year": 2013,
"posterUrl": "/library/metadata/48498/thumb/1601864977",
"imdbId": "",
"language": "en",
"overview": "Batman has stopped the reign of terror that The Mutants had cast upon his city. Now an old foe wants a reunion and the government wants The Man of Steel to put a stop to Batman.",
"moviesInCollection": [],
"ratingKey": 48498,
"key": "/library/metadata/48498",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Batman vs Teenage Mutant Ninja Turtles",
"year": 2019,
"posterUrl": "/library/metadata/48534/thumb/1601864983",
"imdbId": "",
"language": "en",
"overview": "Batman, Batgirl and Robin forge an alliance with the Teenage Mutant Ninja Turtles to fight against the Turtles' sworn enemy, The Shredder, who has apparently teamed up with Ra's Al Ghul and The League of Assassins.",
"moviesInCollection": [],
"ratingKey": 48534,
"key": "/library/metadata/48534",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Being John Malkovich",
"year": 1999,
"posterUrl": "/library/metadata/48594/thumb/1601865002",
"imdbId": "",
"language": "en",
"overview": "A puppeteer discovers a portal that leads literally into the head of movie star John Malkovich.",
"moviesInCollection": [],
"ratingKey": 48594,
"key": "/library/metadata/48594",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Batman Under the Red Hood",
"year": 2010,
"posterUrl": "/library/metadata/48499/thumb/1601864977",
"imdbId": "",
"language": "en",
"overview": "Batman faces his ultimate challenge as the mysterious Red Hood takes Gotham City by firestorm. One part vigilante, one part criminal kingpin, Red Hood begins cleaning up Gotham with the efficiency of Batman, but without following the same ethical code.",
"moviesInCollection": [],
"ratingKey": 48499,
"key": "/library/metadata/48499",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Big Hero 6",
"year": 2014,
"posterUrl": "/library/metadata/48602/thumb/1601865010",
"imdbId": "",
"language": "en",
"overview": "The special bond develops between plus-sized inflatable robot Baymax, and prodigy Hiro Hamada. They team up with a group of friends to form a band of high-tech heroes.",
"moviesInCollection": [],
"ratingKey": 48602,
"key": "/library/metadata/48602",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Bayonetta Bloody Fate",
"year": 2013,
"posterUrl": "/library/metadata/48538/thumb/1601864988",
"imdbId": "",
"language": "en",
"overview": "Bayonetta: Bloody Fate follows the story of the witch Bayonetta, as she defeats the blood-thirsty Angels and tries to remember her past from before the time she awoke, 20 years ago. Along her side are a mysterious little girl who keeps calling her \"Mummy\", a journalist that holds a personal grudge against Bayonetta and a unknown white-haired woman who seems to know more than she is willing to reveal about Bayonetta's time before her sleep.",
"moviesInCollection": [],
"ratingKey": 48538,
"key": "/library/metadata/48538",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
},
{
"name": "Bedazzled",
"year": 2000,
"posterUrl": "/library/metadata/48588/thumb/1601864997",
"imdbId": "",
"language": "en",
"overview": "Elliot Richardson, a suicidal techno geek, is given seven wishes to turn his life around when he meets a very seductive Satan. The catch: his soul. Some of his wishes include a 7 foot basketball star, a rock star, and a hamburger. But, as could be expected, the Devil puts her own little twist on each of his fantasies.",
"moviesInCollection": [],
"ratingKey": 48588,
"key": "/library/metadata/48588",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
}
]
}
+20
View File
@@ -0,0 +1,20 @@
{
"code": 40,
"reason": "Plex's library movies found.",
"extras": [
{
"name": "Saw",
"year": 2004,
"posterUrl": "/library/metadata/48756/thumb/1601867828",
"imdbId": "tt0387564",
"language": "en",
"overview": "Obsessed with teaching his victims the value of life, a deranged, sadistic serial killer abducts the morally wayward. Once captured, they must face impossible choices in a horrific game of survival. The victims must fight to win their lives back, or die trying...",
"moviesInCollection": [],
"ratingKey": 48756,
"key": "/library/metadata/48756",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": -1
}
]
}
+328
View File
@@ -0,0 +1,328 @@
{
"code": 40,
"reason": "Plex's library movies found.",
"extras": [
{
"name": "Dragon Ball Z Broly Second Coming",
"year": 1994,
"posterUrl": "/library/metadata/48762/thumb/1601866905",
"imdbId": "tt0142239",
"language": "en",
"overview": "A Saiyan Space pod crash-lands on Earth out of which a wounded Saiyan crawls: Broly, the Legendary Super Saiyan. The wounded Broly shouts out in frustration and turns into normal form. The place soon freezes, trapping him in it and he falls into a coma.",
"moviesInCollection": [],
"ratingKey": 48762,
"key": "/library/metadata/48762",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 44251
},
{
"name": "Dragon Ball Z Broly The Legendary Super Saiyan",
"year": 1993,
"posterUrl": "/library/metadata/48763/thumb/1601866916",
"imdbId": "tt0142242",
"language": "en",
"overview": "While the Saiyan Paragus persuades Vegeta to rule a new planet, King Kai alerts Goku of the South Galaxy's destruction by an unknown Super Saiyan.",
"moviesInCollection": [],
"ratingKey": 48763,
"key": "/library/metadata/48763",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 34433
},
{
"name": "Dragon Ball Z Dead Zone",
"year": 1989,
"posterUrl": "/library/metadata/48767/thumb/1601866938",
"imdbId": "tt0142235",
"language": "en",
"overview": "Gohan has been kidnapped! To make matters worse, the evil Garlic Jr. is gathering the Dragonballs to wish for immortality. Only then will Garlic Jr. be able to take over the Earth in order to gain revenge for the death of his father. Goku rushes to save Gohan, but arrives at the fortress just as Garlic Jr. summons the Eternal Dragon! Krillin and Piccolo try to help Goku, but their combined powers.",
"moviesInCollection": [],
"ratingKey": 48767,
"key": "/library/metadata/48767",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 28609
},
{
"name": "Dragon Ball Z The Tree of Might",
"year": 1990,
"posterUrl": "/library/metadata/48778/thumb/1601867446",
"imdbId": "tt0142233",
"language": "en",
"overview": "Goku and friends must stop a band of space pirates from consuming fruit from the Tree of Might before it's destructive powers drain Earth's energy.",
"moviesInCollection": [],
"ratingKey": 48778,
"key": "/library/metadata/48778",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39101
},
{
"name": "X-Men Days of Future Past",
"year": 2014,
"posterUrl": "/library/metadata/48737/thumb/1601888885",
"imdbId": "tt1877832",
"language": "en",
"overview": "The ultimate X-Men ensemble fights a war for the survival of the species across two time periods as they join forces with their younger selves in an epic battle that must change the past to save our future.",
"moviesInCollection": [],
"ratingKey": 48737,
"key": "/library/metadata/48737",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 127585
},
{
"name": "Dragon Ball Z Bio-Broly",
"year": 1994,
"posterUrl": "/library/metadata/48759/thumb/1601866890",
"imdbId": "tt0142234",
"language": "en",
"overview": "Jaga Bada, Mr. Satan's old sparring partner, has invited Satan to his personal island to hold a grudge match. Trunks and Goten decide to come for the adventure and Android #18 is following Satan for the money he owes her. Little do they know that Jaga Bada's scientist have found a way to resurrect Broly, the legendary Super Saiyan.",
"moviesInCollection": [],
"ratingKey": 48759,
"key": "/library/metadata/48759",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39106
},
{
"name": "Dragon Ball Z The World's Strongest",
"year": 1990,
"posterUrl": "/library/metadata/48779/thumb/1601867458",
"imdbId": "tt0142240",
"language": "en",
"overview": "The evil Dr. Kochin uses the dragon balls to resurrect his mentor, Dr. Wheelo, in an effort to take over the world. Dr. Wheelo, his body having been destroyed by the avalanche that killed him fifty years before, desires the body of the strongest fighter in the world as his new vessel. Believing Roshi to be the world's strongest warrior, Dr. Kochin abducts Bulma and forces Roshi to surrender himself to save her. When Goku hears of their abduction, he goes to their rescue.",
"moviesInCollection": [],
"ratingKey": 48779,
"key": "/library/metadata/48779",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39100
},
{
"name": "Dragon Ball Curse of the Blood Rubies",
"year": 1986,
"posterUrl": "/library/metadata/48754/thumb/1601866106",
"imdbId": "tt0142251",
"language": "en",
"overview": "The great King Gurumes is searching for the Dragon Balls in order to put a stop to his endless hunger. A young girl named Pansy who lives in the nearby village has had enough of the treachery and decides to seek Muten Rōshi for assistance. Can our heroes save the village and put a stop to the Gurumes Army?",
"moviesInCollection": [],
"ratingKey": 48754,
"key": "/library/metadata/48754",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39144
},
{
"name": "Dragon Ball Mystical Adventure",
"year": 1988,
"posterUrl": "/library/metadata/48748/thumb/1601866053",
"imdbId": "tt0142248",
"language": "en",
"overview": "Master Roshi has succeeded at the one mission he valued most: to train Goku and Krillin to become ultimate fighters. So, he arranges for them to test their mettle at a competition hosted by Emperor Chiaotzu. Not everyone's playing by the rules, however, as a member of the ruler's household schemes to use the Dragonballs to extort money and power from the royal.",
"moviesInCollection": [],
"ratingKey": 48748,
"key": "/library/metadata/48748",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 116776
},
{
"name": "Dragon Ball Z Lord Slug",
"year": 1991,
"posterUrl": "/library/metadata/48769/thumb/1601866969",
"imdbId": "tt0142244",
"language": "en",
"overview": "A Super Namekian named Slug comes to invade Earth. But the Z Warriors do their best to stop Slug and his gang.",
"moviesInCollection": [],
"ratingKey": 48769,
"key": "/library/metadata/48769",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39102
},
{
"name": "X-Men",
"year": 2000,
"posterUrl": "/library/metadata/48735/thumb/1601888898",
"imdbId": "tt0120903",
"language": "en",
"overview": "Two mutants, Rogue and Wolverine, come to a private academy for their kind whose resident superhero team, the X-Men, must oppose a terrorist organization with similar powers.",
"moviesInCollection": [],
"ratingKey": 48735,
"key": "/library/metadata/48735",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 36657
},
{
"name": "Dragon Ball Z Bardock - The Father of Goku",
"year": 1990,
"posterUrl": "/library/metadata/48734/thumb/1601865971",
"imdbId": "tt0142245",
"language": "en",
"overview": "Bardock, Son Goku's father, is a low-ranking Saiyan soldier who was given the power to see into the future by the last remaining alien on a planet he just destroyed. He witnesses the destruction of his race and must now do his best to stop Frieza's impending massacre.",
"moviesInCollection": [],
"ratingKey": 48734,
"key": "/library/metadata/48734",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39323
},
{
"name": "Dragon Ball Z Battle of Gods",
"year": 2013,
"posterUrl": "/library/metadata/48749/thumb/1601866054",
"imdbId": "tt2263944",
"language": "en",
"overview": "The events of Battle of Gods take place some years after the battle with Majin Buu, which determined the fate of the entire universe. After awakening from a long slumber, Beerus, the God of Destruction is visited by Whis, his attendant and learns that the galactic overlord Frieza has been defeated by a Super Saiyan from the North Quadrant of the universe named Goku, who is also a former student of the North Kai. Ecstatic over the new challenge, Goku ignores King Kai's advice and battles Beerus, but he is easily overwhelmed and defeated. Beerus leaves, but his eerie remark of \"Is there nobody on Earth more worthy to destroy?\" lingers on. Now it is up to the heroes to stop the God of Destruction before all is lost.",
"moviesInCollection": [],
"ratingKey": 48749,
"key": "/library/metadata/48749",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 126963
},
{
"name": "Dragon Ball Z The Return of Cooler",
"year": 1992,
"posterUrl": "/library/metadata/48775/thumb/1601867335",
"imdbId": "tt0142237",
"language": "en",
"overview": "Cooler has resurrected himself as a robot and is enslaving the people of New Namek. Goku and the gang must help.",
"moviesInCollection": [],
"ratingKey": 48775,
"key": "/library/metadata/48775",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39103
},
{
"name": "Dragon Ball Z Bojack Unbound",
"year": 1993,
"posterUrl": "/library/metadata/48760/thumb/1601866897",
"imdbId": "tt0142238",
"language": "en",
"overview": "Mr. Money is holding another World Martial Arts Tournament and Mr. Satan invites everyone in the world to join in. Little does he know that Bojack, an ancient villain who has escaped his prison, is competing. Since Goku is currently dead, it is up to Gohan, Vegeta, and Trunks to defeat Bojack and his henchman.",
"moviesInCollection": [],
"ratingKey": 48760,
"key": "/library/metadata/48760",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39105
},
{
"name": "Dragon Ball Z Resurrection 'F'",
"year": 2015,
"posterUrl": "/library/metadata/48770/thumb/1601867255",
"imdbId": "tt3819668",
"language": "en",
"overview": "One peaceful day on Earth, two remnants of Frieza's army named Sorbet and Tagoma arrive searching for the Dragon Balls with the aim of reviving Frieza. They succeed, and Frieza subsequently seeks revenge on the Saiyans.",
"moviesInCollection": [],
"ratingKey": 48770,
"key": "/library/metadata/48770",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 303857
},
{
"name": "Dragon Ball Z The History of Trunks",
"year": 1993,
"posterUrl": "/library/metadata/48777/thumb/1601867430",
"imdbId": "tt0142247",
"language": "en",
"overview": "It has been thirteen years since the Androids began their killing rampage and Son Gohan is the only person fighting back. He takes Bulma's son Trunks as a student and even gives his own life to save Trunks's. Now Trunks must figure out a way to change this apocalyptic future",
"moviesInCollection": [],
"ratingKey": 48777,
"key": "/library/metadata/48777",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39324
},
{
"name": "Dragon Ball Z Wrath of the Dragon",
"year": 1995,
"posterUrl": "/library/metadata/48780/thumb/1601867465",
"imdbId": "tt0142243",
"language": "en",
"overview": "The Z Warriors discover an unopenable music box and are told to open it with the Dragon Balls. The contents turn out to be a warrior named Tapion who had sealed himself inside along with a monster called Hildegarn. Goku must now perfect a new technique to defeat the evil monster.",
"moviesInCollection": [],
"ratingKey": 48780,
"key": "/library/metadata/48780",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39108
},
{
"name": "Dragon Ball Z Cooler's Revenge",
"year": 1991,
"posterUrl": "/library/metadata/48765/thumb/1601866926",
"imdbId": "tt1125254",
"language": "en",
"overview": "After defeating Frieza, Goku returns to Earth and goes on a camping trip with Gohan and Krillin. Everything is normal until Cooler - Frieza's brother - sends three henchmen after Goku. A long fight ensues between our heroes and Cooler, in which he transforms into the fourth stage of his evolution and has the edge in the fight... until Goku transforms into a Super Saiyan.",
"moviesInCollection": [],
"ratingKey": 48765,
"key": "/library/metadata/48765",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 24752
},
{
"name": "Dragon Ball Z Fusion Reborn",
"year": 1995,
"posterUrl": "/library/metadata/48768/thumb/1601866949",
"imdbId": "tt0142236",
"language": "en",
"overview": "Not paying attention to his job, a young demon allows the evil cleansing machine to overflow and explode, turning the young demon into the infamous monster Janemba. Goku and Vegeta make solo attempts to defeat the monster, but realize their only option is fusion.",
"moviesInCollection": [],
"ratingKey": 48768,
"key": "/library/metadata/48768",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39107
},
{
"name": "Dragon Ball The Path to Power",
"year": 1996,
"posterUrl": "/library/metadata/48755/thumb/1601866122",
"imdbId": "tt0142250",
"language": "en",
"overview": "A retelling of Dragon Ball's origin with a different take on the meeting of Goku, Bulma, and Kame-Sen'nin. It also retells the Red Ribbon Army story; but this time they find Goku rather than Goku finding them.",
"moviesInCollection": [],
"ratingKey": 48755,
"key": "/library/metadata/48755",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39148
},
{
"name": "Dragon Ball Super Broly",
"year": 2018,
"posterUrl": "/library/metadata/48753/thumb/1601866095",
"imdbId": "tt7961060",
"language": "en",
"overview": "Earth is peaceful following the Tournament of Power. Realizing that the universes still hold many more strong people yet to see, Goku spends all his days training to reach even greater heights. Then one day, Goku and Vegeta are faced by a Saiyan called 'Broly' who they've never seen before. The Saiyans were supposed to have been almost completely wiped out in the destruction of Planet Vegeta, so what's this one doing on Earth? This encounter between the three Saiyans who have followed completely different destinies turns into a stupendous battle, with even Frieza (back from Hell) getting caught up in the mix.",
"moviesInCollection": [],
"ratingKey": 48753,
"key": "/library/metadata/48753",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 503314
},
{
"name": "Dragon Ball Z Super Android 13!",
"year": 1992,
"posterUrl": "/library/metadata/48776/thumb/1601867343",
"imdbId": "tt0142241",
"language": "en",
"overview": "Dr. Gero's Androids #13, #14, and #15 are awakened by the laboratory computers and immediately head to the mall where Goku is shopping. After Goku, Trunks, and Vegeta defeat #14 and #15, #13 absorbs their inner computers and becomes a super being greater than the original three separately were. Now it is up to Goku to stop him.",
"moviesInCollection": [],
"ratingKey": 48776,
"key": "/library/metadata/48776",
"collectionTitle": "",
"collectionId": -1,
"tmdbId": 39104
}
]
}
+10 -67
View File
@@ -31,66 +31,6 @@ export function spyOnAddEventListener(win) {
};
}
export function searchPlexForMoviesFromSaw(cy) {
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="2"]')
.first()
.click();
cy.get('.card-body > .btn')
.click();
cy.get('label > input')
.clear()
.type('Saw');
cy.get('#movies_info')
.should('have.text', 'Showing 1 to 1 of 1 entries');
cy.get('.card-img')
.should('be.visible')
.and(($img) => {
// "naturalWidth" and "naturalHeight" are set when the image loads
expect($img[0].naturalWidth).to.be.greaterThan(0);
});
}
export function searchPlexForMoviesFromBestMovies(cy) {
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="5"]')
.first()
.click();
cy.get('.card-body > .btn')
.click();
// Wait for timeout from clearing data
cy.wait(5000);
}
export function searchPlexForMoviesFromMovies(cy) {
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="1"]')
.first()
.click();
cy.get('.card-body > .btn')
.click();
cy.get('label > input')
.clear()
.type('Gods');
cy.get('#movies_info')
.should('have.text', 'Showing 1 to 1 of 1 entries (filtered from 21 total entries)');
}
export function nuke() {
cy.request('PUT', '/nuke')
.then((response) => {
@@ -120,8 +60,8 @@ export function redLibraryBefore() {
cy.get('#address')
.clear()
.type(atob('MTkyLjE2OC4xLjk='))
.should('have.value', atob('MTkyLjE2OC4xLjk='));
.type(atob('MTkyLjE2OC4xLjg='))
.should('have.value', atob('MTkyLjE2OC4xLjg='));
cy.get('#port')
.clear()
@@ -164,16 +104,19 @@ export function redLibraryBefore() {
.should('not.be.visible');
// Define card here
cy.get('.card-header')
.should('have.text', 'Red');
cy.get('[data-cy=Joker]')
.should('have.text', 'Joker');
cy.get('.list-group > :nth-child(1)')
cy.get('[data-cy="Best Movies"]')
.should('have.text', 'Best Movies');
cy.get('.list-group > :nth-child(2)')
cy.get('[data-cy="Movies"]')
.should('have.text', 'Movies');
cy.get('[data-cy="Movies with new Metadata"]')
.should('have.text', 'Movies with new Metadata');
cy.get('.list-group > :nth-child(3)')
cy.get('[data-cy=Saw]')
.should('have.text', 'Saw');
}
+18 -12
View File
@@ -83,8 +83,8 @@ describe('Plex Configuration Tests', () => {
it('Test valid new Plex Server', () => {
cy.get('#address')
.clear()
.type(atob('MTkyLjE2OC4xLjk='))
.should('have.value', atob('MTkyLjE2OC4xLjk='));
.type(atob('MTkyLjE2OC4xLjg='))
.should('have.value', atob('MTkyLjE2OC4xLjg='));
cy.get('#port')
.clear()
@@ -178,8 +178,8 @@ describe('Plex Configuration Tests', () => {
it('Save valid Plex Server', () => {
cy.get('#address')
.clear()
.type(atob('MTkyLjE2OC4xLjk='))
.should('have.value', atob('MTkyLjE2OC4xLjk='));
.type(atob('MTkyLjE2OC4xLjg='))
.should('have.value', atob('MTkyLjE2OC4xLjg='));
cy.get('#port')
.clear()
@@ -220,15 +220,18 @@ describe('Plex Configuration Tests', () => {
// Define card here
cy.get('.card-header')
.should('have.text', 'Red');
.should('have.text', 'Joker');
cy.get('.list-group > :nth-child(1)')
.should('have.text', 'Best Movies');
cy.get('.list-group > :nth-child(2)')
.should('have.text', 'Movies with new Metadata');
.should('have.text', 'Movies');
cy.get('.list-group > :nth-child(3)')
.should('have.text', 'Movies with new Metadata');
cy.get('.list-group > :nth-child(4)')
.should('have.text', 'Saw');
});
@@ -293,8 +296,8 @@ describe('Plex Configuration Tests', () => {
it('Save duplicate valid Plex Server', () => {
cy.get('#address')
.clear()
.type(atob('MTkyLjE2OC4xLjk='))
.should('have.value', atob('MTkyLjE2OC4xLjk='));
.type(atob('MTkyLjE2OC4xLjg='))
.should('have.value', atob('MTkyLjE2OC4xLjg='));
cy.get('#port')
.clear()
@@ -335,21 +338,24 @@ describe('Plex Configuration Tests', () => {
// Define card here
cy.get('.card-header')
.should('have.text', 'Red');
.should('have.text', 'Joker');
cy.get('.list-group > :nth-child(1)')
.should('have.text', 'Best Movies');
cy.get('.list-group > :nth-child(2)')
.should('have.text', 'Movies with new Metadata');
.should('have.text', 'Movies');
cy.get('.list-group > :nth-child(3)')
.should('have.text', 'Movies with new Metadata');
cy.get('.list-group > :nth-child(4)')
.should('have.text', 'Saw');
cy.get('#address')
.clear()
.type('192.168.1.9')
.should('have.value', '192.168.1.9');
.type('192.168.1.8')
.should('have.value', '192.168.1.8');
cy.get('#port')
.clear()
@@ -8,10 +8,12 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* global cy, it, describe, before, expect */
/* global cy, it, describe, beforeEach, expect */
/* eslint no-undef: "error" */
import { redLibraryBefore, searchPlexForMoviesFromBestMovies, spyOnAddEventListener } from '../common.js';
import {
nuke, redLibraryBefore, spyOnAddEventListener,
} from '../common.js';
function checkForDuplicates(ownedMovies, recommendedMovies) {
cy.log(`recommendedMovies.length: ${recommendedMovies.length}`);
@@ -39,7 +41,51 @@ function checkForDuplicates(ownedMovies, recommendedMovies) {
function searchBestMovieLibrary(cy) {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
searchPlexForMoviesFromBestMovies(cy);
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-cy="Best Movies"]')
.first()
.click();
cy.get('[data-cy=searchForMovies]')
.click();
// Wait for timeout from clearing data
cy.wait(5000);
cy.visit('/recommended', { onBeforeLoad: spyOnAddEventListener });
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-cy="Best Movies"]')
.first()
.click();
cy.get('[data-cy=searchForMovies]')
.click();
}
function searchMovieWithNewMetadataLibrary(cy) {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-cy="Movies with new Metadata"]')
.first()
.click();
cy.get('[data-cy=searchForMovies]')
.click();
cy.get('label > input')
.clear()
.type('God');
cy.get('#movies_info')
.contains('Showing 1 to 1 of 1 entries');
cy.visit('/recommended', { onBeforeLoad: spyOnAddEventListener });
}
@@ -56,58 +102,36 @@ function waitUtilSearchingIsDone() {
}
describe('Search for Duplicates', () => {
before(redLibraryBefore);
beforeEach(nuke);
beforeEach(redLibraryBefore);
it('Check Best Movies and Recommended for Duplicates', () => {
searchBestMovieLibrary(cy);
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="5"]')
.first()
.click();
cy.get('.card-body > .btn')
.click();
waitUtilSearchingIsDone();
let ownedMovies;
cy.request('/plex/movies/721fee4db63634b88ed699f8b0a16d7682a7a0d9/5')
cy.request('/plex/movies/c51c432ae94e316d52570550f915ecbcd71bede8/1')
.then((resp) => {
ownedMovies = resp.body;
cy.log(`ownedMovies.length: ${ownedMovies.length}`);
}).request('/recommended/721fee4db63634b88ed699f8b0a16d7682a7a0d9/5')
}).request('/recommended/c51c432ae94e316d52570550f915ecbcd71bede8/1')
.then((resp) => {
const recommendedMovies = resp.body.extras;
checkForDuplicates(ownedMovies, recommendedMovies);
});
});
it('Check Saw and Recommended for Duplicates', () => {
it('Check Movies with new Metatdata and Recommended for Duplicates', () => {
searchMovieWithNewMetadataLibrary(cy);
waitUtilSearchingIsDone();
let ownedMovies;
cy.request('/plex/movies/721fee4db63634b88ed699f8b0a16d7682a7a0d9/2')
cy.request('/plex/movies/c51c432ae94e316d52570550f915ecbcd71bede8/4')
.then((resp) => {
ownedMovies = resp.body;
cy.log(`ownedMovies.length: ${ownedMovies.length}`);
}).request('/recommended/721fee4db63634b88ed699f8b0a16d7682a7a0d9/2')
.then((resp) => {
const recommendedMovies = resp.body.extras;
checkForDuplicates(ownedMovies, recommendedMovies);
});
});
it('Check Movies and Recommended for Duplicates', () => {
waitUtilSearchingIsDone();
let ownedMovies;
cy.request('/plex/movies/721fee4db63634b88ed699f8b0a16d7682a7a0d9/1')
.then((resp) => {
ownedMovies = resp.body;
}).request('/recommended/721fee4db63634b88ed699f8b0a16d7682a7a0d9/1')
}).request('/recommended/c51c432ae94e316d52570550f915ecbcd71bede8/4')
.then((resp) => {
const recommendedMovies = resp.body.extras;
checkForDuplicates(ownedMovies, recommendedMovies);
+17 -7
View File
@@ -12,13 +12,24 @@
/* eslint no-undef: "error" */
import {
nuke, redLibraryBefore, searchPlexForMoviesFromSaw, spyOnAddEventListener,
nuke, redLibraryBefore, spyOnAddEventListener,
} from '../common.js';
function searchSawLibrary(cy) {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
searchPlexForMoviesFromSaw(cy);
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-cy=Saw]')
.first()
.click();
cy.get('[data-cy=searchForMovies]')
.click();
cy.get('#movies_info')
.should('have.text', 'Showing 1 to 1 of 1 entries');
cy.visit('/recommended', { onBeforeLoad: spyOnAddEventListener });
}
@@ -33,13 +44,12 @@ describe('Library API', () => {
});
});
before(nuke);
before(redLibraryBefore);
it('Get library Red - Saw', () => {
it('Get library Joker - Saw', () => {
searchSawLibrary(cy);
cy.request('/libraries/721fee4db63634b88ed699f8b0a16d7682a7a0d9/2')
cy.request('/libraries/c51c432ae94e316d52570550f915ecbcd71bede8/5')
.then((resp) => {
cy.log(resp.body);
const result = resp.body;
@@ -52,8 +62,8 @@ describe('Plex Movie List API', () => {
beforeEach(nuke);
beforeEach(redLibraryBefore);
it('Get library Red - Saw', () => {
cy.request('/plex/movies/721fee4db63634b88ed699f8b0a16d7682a7a0d9/2')
it('Get library Joker - Saw', () => {
cy.request('/plex/movies/c51c432ae94e316d52570550f915ecbcd71bede8/5')
.then((resp) => {
cy.log(resp.body);
const result = resp.body;
+3 -3
View File
@@ -20,14 +20,14 @@ describe('Not Searched Yet Library', () => {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
cy.get('#libraryTitle')
.contains('Red');
.contains('Joker');
cy.get('#dropdownMenuLink')
.should('have.text', 'Libraries');
cy.get('[data-key="1"]')
cy.get('[data-cy="Movies with new Metadata"]')
.first()
.should('have.text', 'Red - Movies with new Metadata');
.should('have.text', 'Joker - Movies with new Metadata');
cy.get('.card-img-top')
.should('be.visible');
@@ -12,32 +12,48 @@
/* eslint no-undef: "error" */
import {
jokerLibraryBefore, redLibraryBefore, searchPlexForMoviesFromSaw, spyOnAddEventListener,
redLibraryBefore, nuke, spyOnAddEventListener,
} from '../common.js';
describe('Find owned movies', () => {
before(nuke);
before(redLibraryBefore);
it('Find Movies', () => {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
searchPlexForMoviesFromSaw(cy);
});
it('Refresh Movies', () => {
it('Find Saw Movies', () => {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="1"]')
cy.get('[data-cy=Saw]')
.first()
.click();
cy.get('[data-cy=searchForMovies]')
.click();
cy.get('label > input')
.clear()
.type('Saw');
cy.get('#movies_info')
.should('have.text', 'Showing 1 to 1 of 1 entries');
});
it('Refresh Saw Movies', () => {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-cy="Best Movies"]')
.first()
.click();
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="2"]')
cy.get('[data-cy=Saw]')
.first()
.click();
@@ -56,13 +72,13 @@ describe('Find owned movies', () => {
});
});
it('Research Movies', () => {
it('Research Saw Movies', () => {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="2"]')
cy.get('[data-cy=Saw]')
.first()
.click();
@@ -87,18 +103,16 @@ describe('Find owned movies', () => {
});
});
it('Regular Movies Empty', () => {
jokerLibraryBefore();
it('Movies with Metadata Empty', () => {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="1"][data-machineidentifier="721fee4db63634b88ed699f8b0a16d7682a7a0d9"]')
cy.get('[data-cy="Movies with new Metadata"]')
.click();
cy.get('.card-body > .btn')
cy.get('[data-cy=searchForMovies]')
.should('be.visible');
});
});
@@ -237,79 +237,6 @@ describe('Check Discord Notification Agent', () => {
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check saving and test Discord Notification', () => {
cy.visit('/configuration');
cy.get('#notificationTab')
.click();
cy.get('#discordShowHide')
.click();
checkElements('', CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, 'false');
cy.get('#discordWebHookUrl')
.clear()
.type(atob('aHR0cHM6Ly9kaXNjb3JkYXBwLmNvbS9hcGkvd2ViaG9va3MvNzU2MzExMTkwOTU0NTczOTU2L0Uwa25VRF91akxIQU5oZTA3MGEwYW9PMUNnMGRNQUV4Z1FBbEZGTS1GZUgwNnl3VGExLU42c2ZhREpQSC1lM2dDVEZz'))
.should('have.value', atob('aHR0cHM6Ly9kaXNjb3JkYXBwLmNvbS9hcGkvd2ViaG9va3MvNzU2MzExMTkwOTU0NTczOTU2L0Uwa25VRF91akxIQU5oZTA3MGEwYW9PMUNnMGRNQUV4Z1FBbEZGTS1GZUgwNnl3VGExLU42c2ZhREpQSC1lM2dDVEZz'));
cy.get('#discordTmdbApiConnectionNotification')
.click();
cy.get('#discordPlexServerConnectionNotification')
.click();
cy.get('#discordPlexMetadataUpdateNotification')
.click();
cy.get('#discordPlexLibraryUpdateNotification')
.click();
cy.get('#discordGapsMissingCollectionsNotification')
.click();
cy.get('#discordEnabled')
.select('Enabled');
cy.get('#saveDiscord')
.click();
cy.get('#discordTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#discordTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#discordSaveSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#discordSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#discordSpinner')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#testDiscord')
.click();
cy.wait(2000);
cy.get('#discordTestSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#discordTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#discordSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#discordSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#discordSpinner')
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check Successful Saving and Failure Testing Discord Notification', () => {
cy.visit('/configuration');
@@ -399,118 +399,6 @@ describe('Check Email Notification Agent', () => {
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check saving and test Email Notification', () => {
cy.visit('/configuration');
cy.get('#notificationTab')
.click();
cy.get('#emailShowHide')
.click();
checkElements('', '', '', '', '', 0, 'smtp', 'true', 'false', CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, 'false');
cy.get('#emailUsername')
.clear()
.type(atob('amg1OTc1'))
.should('have.value', atob('amg1OTc1'));
cy.get('#emailPassword')
.clear()
.type(atob('aWJnYnR3aXdyd2xvZWNucA=='))
.should('have.value', atob('aWJnYnR3aXdyd2xvZWNucA=='));
cy.get('#emailMailTo')
.clear()
.type(atob('amg1OTc1QGdtYWlsLmNvbQ=='))
.should('have.value', atob('amg1OTc1QGdtYWlsLmNvbQ=='));
cy.get('#emailMailFrom')
.clear()
.type(atob('amg1OTc1QGdtYWlsLmNvbQ=='))
.should('have.value', atob('amg1OTc1QGdtYWlsLmNvbQ=='));
cy.get('#emailServer')
.clear()
.type(atob('c210cC5nbWFpbC5jb20='))
.should('have.value', atob('c210cC5nbWFpbC5jb20='));
cy.get('#emailPort')
.clear()
.type(atob('NTg3'))
.should('have.value', atob('NTg3'));
cy.get('#emailTransportProtocol')
.clear()
.type(atob('c210cA=='))
.should('have.value', atob('c210cA=='));
cy.get('#emailSmtpAuth')
.clear()
.type(atob('amg1OTc1'))
.should('have.value', atob('amg1OTc1'));
cy.get('#emailSmtpTlsEnabled')
.select('true')
.should('have.value', 'true');
cy.get('#emailTmdbApiConnectionNotification')
.click();
cy.get('#emailPlexServerConnectionNotification')
.click();
cy.get('#emailPlexMetadataUpdateNotification')
.click();
cy.get('#emailPlexLibraryUpdateNotification')
.click();
cy.get('#emailGapsMissingCollectionsNotification')
.click();
cy.get('#emailEnabled')
.select('Enabled');
cy.get('#saveEmail')
.click();
cy.get('#emailTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#emailTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#emailSaveSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#emailSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#emailSpinner')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#testEmail')
.click();
cy.wait(5000);
cy.get('#emailTestSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#emailTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#emailSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#emailSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#emailSpinner')
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check Successful Saving and Failure Testing Email Notification', () => {
cy.visit('/configuration');
@@ -249,84 +249,6 @@ describe('Check Gotify Notification Agent', () => {
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check saving and test Gotify Notification', () => {
cy.visit('/configuration');
cy.get('#notificationTab')
.click();
cy.get('#gotifyShowHide')
.click();
checkElements('', '', CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, 'false');
cy.get('#gotifyAddress')
.clear()
.type(atob('aHR0cDovLzE5Mi4xNjguMS44OjgwNzA='))
.should('have.value', atob('aHR0cDovLzE5Mi4xNjguMS44OjgwNzA='));
cy.get('#gotifyToken')
.clear()
.type(atob('QVJkbS55SHRQUTlhaW5i'))
.should('have.value', atob('QVJkbS55SHRQUTlhaW5i'));
cy.get('#gotifyTmdbApiConnectionNotification')
.click();
cy.get('#gotifyPlexServerConnectionNotification')
.click();
cy.get('#gotifyPlexMetadataUpdateNotification')
.click();
cy.get('#gotifyPlexLibraryUpdateNotification')
.click();
cy.get('#gotifyGapsMissingCollectionsNotification')
.click();
cy.get('#gotifyEnabled')
.select('Enabled');
cy.get('#saveGotify')
.click();
cy.get('#gotifyTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#gotifyTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#gotifySaveSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#gotifySaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#gotifySpinner')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#testGotify')
.click();
cy.wait(2000);
cy.get('#gotifyTestSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#gotifyTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#gotifySaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#gotifySaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#gotifySpinner')
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check Successful Saving and Failure Testing Gotify Notification', () => {
cy.visit('/configuration');
@@ -249,84 +249,6 @@ describe('Check PushBullet Notification Agent', () => {
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check saving and test PushBullet Notification', () => {
cy.visit('/configuration');
cy.get('#notificationTab')
.click();
cy.get('#pushBulletShowHide')
.click();
checkElements('', '', CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, 'false');
cy.get('#pushBulletChannelTag')
.clear()
.type(atob('Z2Fwcw=='))
.should('have.value', atob('Z2Fwcw=='));
cy.get('#pushBulletAccessToken')
.clear()
.type(atob('by5pdjBXbXRuTFdJM3hmaFRTTmh1dVF2Tm1vdlVGSHN6dA=='))
.should('have.value', atob('by5pdjBXbXRuTFdJM3hmaFRTTmh1dVF2Tm1vdlVGSHN6dA=='));
cy.get('#pushBulletTmdbApiConnectionNotification')
.click();
cy.get('#pushBulletPlexServerConnectionNotification')
.click();
cy.get('#pushBulletPlexMetadataUpdateNotification')
.click();
cy.get('#pushBulletPlexLibraryUpdateNotification')
.click();
cy.get('#pushBulletGapsMissingCollectionsNotification')
.click();
cy.get('#pushBulletEnabled')
.select('Enabled');
cy.get('#savePushBullet')
.click();
cy.get('#pushBulletTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushBulletTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushBulletSaveSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#pushBulletSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushBulletSpinner')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#testPushBullet')
.click();
cy.wait(2000);
cy.get('#pushBulletTestSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#pushBulletTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushBulletSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushBulletSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushBulletSpinner')
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check Successful Saving and Failure Testing PushBullet Notification', () => {
cy.visit('/configuration');
@@ -230,102 +230,6 @@ describe('Check PushOver Notification Agent', () => {
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check saving and test PushOver Notification', () => {
cy.visit('/configuration');
cy.get('#notificationTab')
.click();
cy.get('#pushOverShowHide')
.click();
checkElements('', '', 0, 'pushover', '0', '0', CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, 'false');
cy.get('#pushOverToken')
.clear()
.type(atob('YWM1ZjJya2JwejEyMnBqenNlMnBlbmJkdmYxZ2dh'))
.should('have.value', atob('YWM1ZjJya2JwejEyMnBqenNlMnBlbmJkdmYxZ2dh'));
cy.get('#pushOverUser')
.clear()
.type(atob('dTdiemZkZW5kdmRqbnM1eXRrMmV3YjIxZDduaWJ5'))
.should('have.value', atob('dTdiemZkZW5kdmRqbnM1eXRrMmV3YjIxZDduaWJ5'));
cy.get('#pushOverPriority')
.select('1')
.should('have.value', '1');
cy.get('#pushOverSound')
.select('spacealarm')
.should('have.value', 'spacealarm');
cy.get('#pushOverRetry')
.clear()
.type('1')
.should('have.value', '1');
cy.get('#pushOverExpire')
.clear()
.type('2')
.should('have.value', '2');
cy.get('#pushOverTmdbApiConnectionNotification')
.click();
cy.get('#pushOverPlexServerConnectionNotification')
.click();
cy.get('#pushOverPlexMetadataUpdateNotification')
.click();
cy.get('#pushOverPlexLibraryUpdateNotification')
.click();
cy.get('#pushOverGapsMissingCollectionsNotification')
.click();
cy.get('#pushOverEnabled')
.select('Enabled');
cy.get('#savePushOver')
.click();
cy.get('#pushOverTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushOverTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushOverSaveSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#pushOverSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushOverSpinner')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#testPushOver')
.click();
cy.wait(2000);
cy.get('#pushOverTestSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#pushOverTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushOverSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushOverSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#pushOverSpinner')
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check Successful Saving and Failure Testing PushOver Notification', () => {
cy.visit('/configuration');
@@ -188,79 +188,6 @@ describe('Check Slack Notification Agent', () => {
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check saving and test Slack Notification', () => {
cy.visit('/configuration');
cy.get('#notificationTab')
.click();
cy.get('#slackShowHide')
.click();
checkElements('', CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, 'false');
cy.get('#slackWebHookUrl')
.clear()
.type(atob('aHR0cHM6Ly9ob29rcy5zbGFjay5jb20vc2VydmljZXMvVDAxN1hSMEJNUlYvQjAxOEs0TkE3NjAvemsxcVVWMno1N0w4c3lqQ0ExUU8xRFFE'))
.should('have.value', atob('aHR0cHM6Ly9ob29rcy5zbGFjay5jb20vc2VydmljZXMvVDAxN1hSMEJNUlYvQjAxOEs0TkE3NjAvemsxcVVWMno1N0w4c3lqQ0ExUU8xRFFE'));
cy.get('#slackTmdbApiConnectionNotification')
.click();
cy.get('#slackPlexServerConnectionNotification')
.click();
cy.get('#slackPlexMetadataUpdateNotification')
.click();
cy.get('#slackPlexLibraryUpdateNotification')
.click();
cy.get('#slackGapsMissingCollectionsNotification')
.click();
cy.get('#slackEnabled')
.select('Enabled');
cy.get('#saveSlack')
.click();
cy.get('#slackTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#slackTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#slackSaveSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#slackSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#slackSpinner')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#testSlack')
.click();
cy.wait(2000);
cy.get('#slackTestSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#slackTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#slackSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#slackSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#slackSpinner')
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check Successful Saving and Failure Testing Slack Notification', () => {
cy.visit('/configuration');
@@ -180,84 +180,6 @@ describe('Check Telegram Notification Agent', () => {
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check saving and test Telegram Notification', () => {
cy.visit('/configuration');
cy.get('#notificationTab')
.click();
cy.get('#telegramShowHide')
.click();
checkElements('', '', CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, CYPRESS_VALUES.notBeChecked, 'false');
cy.get('#telegramBotId')
.clear()
.type(atob('MTMwMjEzOTExOTpBQUV1cGh0RXVvcFhhVHBpdGlHbFdDWS0zbDMzU0JrUGUybw=='))
.should('have.value', atob('MTMwMjEzOTExOTpBQUV1cGh0RXVvcFhhVHBpdGlHbFdDWS0zbDMzU0JrUGUybw=='));
cy.get('#telegramChatId')
.clear()
.type(atob('MTA0MTA4MTMxNw=='))
.should('have.value', atob('MTA0MTA4MTMxNw=='));
cy.get('#telegramTmdbApiConnectionNotification')
.click();
cy.get('#telegramPlexServerConnectionNotification')
.click();
cy.get('#telegramPlexMetadataUpdateNotification')
.click();
cy.get('#telegramPlexLibraryUpdateNotification')
.click();
cy.get('#telegramGapsMissingCollectionsNotification')
.click();
cy.get('#telegramEnabled')
.select('Enabled');
cy.get('#saveTelegram')
.click();
cy.get('#telegramTestSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#telegramTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#telegramSaveSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#telegramSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#telegramSpinner')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#testTelegram')
.click();
cy.wait(2000);
cy.get('#telegramTestSuccess')
.should(CYPRESS_VALUES.beVisible);
cy.get('#telegramTestError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#telegramSaveSuccess')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#telegramSaveError')
.should(CYPRESS_VALUES.notBeVisible);
cy.get('#telegramSpinner')
.should(CYPRESS_VALUES.notBeVisible);
});
it('Check Successful Saving and Failure Testing Telegram Notification', () => {
cy.visit('/configuration');
+20 -7
View File
@@ -8,17 +8,32 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* global cy, describe, it, before, expect */
/* global cy, describe, it, expect */
/* eslint no-undef: "error" */
import {
nuke, redLibraryBefore, searchPlexForMoviesFromSaw, spyOnAddEventListener,
redLibraryBefore, spyOnAddEventListener,
} from '../common.js';
function searchSawLibrary(cy) {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
searchPlexForMoviesFromSaw(cy);
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-cy=Saw]')
.first()
.click();
cy.get('[data-cy=searchForMovies]')
.click();
cy.get('label > input')
.clear()
.type('Saw');
cy.get('#movies_info')
.should('have.text', 'Showing 1 to 1 of 1 entries');
cy.visit('/recommended', { onBeforeLoad: spyOnAddEventListener });
}
@@ -33,13 +48,11 @@ describe('Recommended API', () => {
});
});
before(nuke);
before(redLibraryBefore);
it('Get library Red - Saw', () => {
redLibraryBefore();
searchSawLibrary(cy);
cy.request('/libraries/721fee4db63634b88ed699f8b0a16d7682a7a0d9/2')
cy.request('/libraries/c51c432ae94e316d52570550f915ecbcd71bede8/5')
.then((resp) => {
cy.log(resp.body);
const result = resp.body;
+2 -2
View File
@@ -25,8 +25,8 @@ describe('Not Searched Yet Recommended', () => {
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="1"]')
cy.get('[data-cy="Movies with new Metadata"]')
.first()
.should('have.text', 'Red - Movies with new Metadata');
.should('have.text', 'Joker - Movies with new Metadata');
});
});
@@ -11,26 +11,42 @@
/* global cy, describe, it, beforeEach */
/* eslint no-undef: "error" */
import { redLibraryBefore, searchPlexForMoviesFromSaw, spyOnAddEventListener } from '../common.js';
import { nuke, redLibraryBefore, spyOnAddEventListener } from '../common.js';
function searchSawLibrary(cy) {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
searchPlexForMoviesFromSaw(cy);
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-cy=Saw]')
.first()
.click();
cy.get('[data-cy=searchForMovies]')
.click();
cy.get('label > input')
.clear()
.type('Saw');
cy.get('#movies_info')
.should('have.text', 'Showing 1 to 1 of 1 entries');
cy.visit('/recommended', { onBeforeLoad: spyOnAddEventListener });
}
describe('Search for Recommended', () => {
beforeEach(nuke);
beforeEach(redLibraryBefore);
it('Clean configuration page load', () => {
searchSawLibrary(cy);
cy.get('#libraryTitle').then(($libraryTitle) => {
if ($libraryTitle.text() !== 'Red - Saw') {
if ($libraryTitle.text() !== 'Joker - Saw') {
cy.get('#dropdownMenuLink').click();
cy.get('[data-key="2"]')
cy.get('[data-cy=Saw]')
.first()
.click();
}
@@ -46,11 +62,11 @@ describe('Search for Recommended', () => {
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="2"]')
cy.get('[data-cy=Saw]')
.first()
.click();
cy.get('.card-body > .btn')
cy.get('[data-cy=searchForMovies]')
.click();
cy.wait(5000);
@@ -65,11 +81,11 @@ describe('Search for Recommended', () => {
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="2"]')
cy.get('[data-cy=Saw]')
.first()
.click();
cy.get('.card-body > .btn')
cy.get('[data-cy=searchForMovies]')
.click();
cy.wait(5000);
+20 -5
View File
@@ -11,12 +11,27 @@
/* global cy, describe, it, before, expect */
/* eslint no-undef: "error" */
import { redLibraryBefore, searchPlexForMoviesFromSaw, spyOnAddEventListener } from '../common.js';
import { redLibraryBefore, spyOnAddEventListener } from '../common.js';
function searchSawLibrary(cy) {
cy.visit('/libraries', { onBeforeLoad: spyOnAddEventListener });
searchPlexForMoviesFromSaw(cy);
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-cy=Saw]')
.first()
.click();
cy.get('[data-cy=searchForMovies]')
.click();
cy.get('label > input')
.clear()
.type('Saw');
cy.get('#movies_info')
.should('have.text', 'Showing 1 to 1 of 1 entries');
cy.visit('/recommended', { onBeforeLoad: spyOnAddEventListener });
}
@@ -30,11 +45,11 @@ describe('Searched RSS', () => {
cy.get('#dropdownMenuLink')
.click();
cy.get('[data-key="2"]')
cy.get('[data-cy=Saw]')
.first()
.click();
cy.get('.card-body > .btn')
cy.get('[data-cy=searchForMovies]')
.click();
cy.wait(5000);
@@ -44,7 +59,7 @@ describe('Searched RSS', () => {
cy.visit('/rssCheck', { onBeforeLoad: spyOnAddEventListener });
cy.request('/rss/721fee4db63634b88ed699f8b0a16d7682a7a0d9/2')
cy.request('/rss/c51c432ae94e316d52570550f915ecbcd71bede8/5')
.then((resp) => {
const result = resp.body;
expect(result).to.have.lengthOf(7);