Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 5 additions & 30 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "io.spring.dependency-management" version "1.1.4"
id "io.spring.dependency-management" version "1.1.7"
id 'java'
id 'jacoco'
id "com.github.node-gradle.node" version "2.2.1"
Expand Down Expand Up @@ -38,48 +38,23 @@ dependencyManagement {
}
}

ext['junit-jupiter.version'] = "${junitVersion}"
ext['spring-boot.version'] = "${springBootVersion}"

dependencies {
if (releaseMode) {
implementation 'com.epam.reportportal:commons-dao'
implementation 'com.epam.reportportal:plugin-api'
annotationProcessor 'com.epam.reportportal:plugin-api'
} else {
implementation 'com.github.reportportal:commons-dao:a98c172'
implementation 'com.github.reportportal:plugin-api:develop-SNAPSHOT'
annotationProcessor 'com.github.reportportal:plugin-api:develop-SNAPSHOT'
implementation 'com.github.reportportal:commons-dao:196d4ac'
implementation 'com.github.reportportal:plugin-api:8874441'
annotationProcessor 'com.github.reportportal:plugin-api:8874441'
}

compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"

implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2'
implementation 'org.hibernate:hibernate-core:5.6.15.Final'
testImplementation 'org.mockito:mockito-core:5.14.2'
testImplementation 'org.mockito:mockito-junit-jupiter:5.14.2'
testImplementation "org.junit.jupiter:junit-jupiter"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-engine"
testImplementation 'net.bytebuddy:byte-buddy:1.14.9'
}

test {
useJUnitPlatform()
maxParallelForks = 1
testLogging {
events = ['failed']
exceptionFormat = 'short'
}
reports {
junitXml.required = true
}
}

build.dependsOn jacocoTestReport

artifacts {
archives shadowJar
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version=1.0.0
version=1.1.0
description=EPAM Report Portal. Telegram plugin.
pluginId=telegram
lombokVersion=1.18.36
junitVersion=5.11.0
springBootVersion=3.4.2
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;
import javax.sql.DataSource;
import org.pf4j.Extension;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.task.TaskExecutor;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.web.client.RestTemplate;

Expand All @@ -79,6 +81,10 @@ public class TelegramPluginExtension implements ReportPortalExtensionPoint, Disp

public static final String SCRIPTS_DIR = "scripts";

private static final String NAME_FIELD = "name";

private static final String PLUGIN_NAME = "Telegram";

private final Supplier<Map<String, PluginCommand>> pluginCommandMapping = new MemoizingSupplier<>(
this::getCommands);

Expand Down Expand Up @@ -187,6 +193,7 @@ private void removeListeners() {
@Override
public Map<String, ?> getPluginParams() {
Map<String, Object> params = new HashMap<>();
params.put(NAME_FIELD, PLUGIN_NAME);
params.put(ALLOWED_COMMANDS, new ArrayList<>(pluginCommandMapping.get().keySet()));
params.put(DOCUMENTATION_LINK_FIELD, DOCUMENTATION_LINK);
params.put(COMMON_COMMANDS, new ArrayList<>(commonPluginCommandMapping.get().keySet()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang3.BooleanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand All @@ -44,6 +46,8 @@
public class TelegramLaunchFinishEventListener implements
ApplicationListener<LaunchFinishedPluginEvent> {

private static final Logger LOGGER = LoggerFactory.getLogger(TelegramLaunchFinishEventListener.class);

public final static String TELEGRAM_NOTIFICATION_ATTRIBUTE = "notifications.telegram.enabled";
public final static String CHAT_ID = "chatId";

Expand Down Expand Up @@ -74,10 +78,14 @@ public TelegramLaunchFinishEventListener(

@Override
public void onApplicationEvent(LaunchFinishedPluginEvent event) {
Project project = getProject(event.getProjectId());
if (isNotificationsEnabled(project)) {
Launch launch = getLaunch(event.getSource());
processSenderCases(project, launch, event.getLaunchLink());
try {
Project project = getProject(event.getProjectId());
if (isNotificationsEnabled(project)) {
Launch launch = getLaunch(event.getSource());
processSenderCases(project, launch, event.getLaunchLink());
}
} catch (Exception e) {
LOGGER.error("Failed to process Telegram notification for launch");
}
}

Expand Down