Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APP-3054: new legacy and BDK2.0 release #211

Merged
merged 4 commits into from
Sep 11, 2020
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
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-java</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
<name>Symphony Java BDK Project</name>
<description>Symphony Java BDK Parent</description>
<url>https://github.com/SymphonyPlatformSolutions/symphony-api-client-java</url>
Expand Down Expand Up @@ -185,6 +185,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<failOnError>false</failOnError>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand All @@ -207,6 +210,17 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
3 changes: 2 additions & 1 deletion symphony-bdk-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<parent>
<artifactId>symphony-bdk-java</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</parent>

<artifactId>symphony-bdk-bom</artifactId>
<version>1.2.1.BETA</version>
<packaging>pom</packaging>
<name>Symphony Java BDK BOM</name>
<description>Symphony Java BDK Bom (Bill Of Materials)</description>
Expand Down
3 changes: 2 additions & 1 deletion symphony-bdk-core-invokers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<parent>
<artifactId>symphony-bdk-java</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</parent>

<artifactId>symphony-bdk-core-invokers</artifactId>
<version>1.2.1.BETA</version>
<name>Symphony Java BDK Core Invokers</name>
<description>Symphony Java BDK Core Invokers Module</description>
<packaging>pom</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>symphony-bdk-core-invokers</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1.BETA</version>
</parent>

<artifactId>symphony-bdk-core-invoker-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>symphony-bdk-core-invokers</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1.BETA</version>
</parent>

<artifactId>symphony-bdk-core-invoker-jersey2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ protected boolean isJsonMime(String mime) {
* @param formParams Form parameters
* @param contentType Context type
* @return Entity
* @throws ApiException API exception
*/
protected Entity<?> serialize(Object obj, Map<String, Object> formParams, String contentType) {
Entity<?> entity;
Expand Down
3 changes: 2 additions & 1 deletion symphony-bdk-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<parent>
<artifactId>symphony-bdk-java</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</parent>

<artifactId>symphony-bdk-core</artifactId>
<version>1.2.1.BETA</version>
<name>Symphony Java BDK Core </name>
<description>Symphony Java BDK Core Module</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.ProcessingException;

/**
* Base class for implementing the datafeed services. A datafeed services can help a bot subscribe or unsubscribe
* a {@link RealTimeEventListener} and handle the received event by the subscribed listeners.
Expand Down Expand Up @@ -44,7 +46,7 @@ public AbstractDatafeedService(DatafeedApi datafeedApi, AuthSession authSession,
ApiException apiException = (ApiException) e;
return apiException.isServerError() || apiException.isUnauthorized();
}
return false;
return e instanceof ProcessingException;
})
.build();
}
Expand Down Expand Up @@ -101,6 +103,9 @@ protected Retry getRetryInstance(String name, RetryConfig... config) {
retry.getEventPublisher().onRetry(event -> {
long intervalInMillis = event.getWaitInterval().toMillis();
double interval = intervalInMillis / 1000.0;
if (event.getLastThrowable() != null) {
log.debug("Datafeed service failed due to {}", event.getLastThrowable().getMessage());
}
log.info("Retry in {} secs...", interval);
});
return retry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;

import javax.ws.rs.ProcessingException;

/**
* A class for implementing the datafeed v1 service.
*
Expand Down Expand Up @@ -93,7 +95,7 @@ private void readDatafeed() throws Throwable {
ApiException apiException = (ApiException) e;
return apiException.isServerError() || apiException.isUnauthorized() || apiException.isClientError();
}
return false;
return e instanceof ProcessingException;
}).build();
Retry retry = this.getRetryInstance("Read Datafeed", config);
retry.executeCheckedSupplier(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import javax.ws.rs.ProcessingException;

/**
* A class for implementing the datafeed v2 service.
*
Expand Down Expand Up @@ -132,7 +134,7 @@ private void readDatafeed() throws Throwable {
ApiException apiException = (ApiException) e;
return apiException.isServerError() || apiException.isUnauthorized() || apiException.isClientError();
}
return false;
return e instanceof ProcessingException;
}).build();
Retry retry = this.getRetryInstance("Read Datafeed", config);
retry.executeCheckedSupplier(() -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.symphony.bdk.core.service.datafeed.impl;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -52,6 +56,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketTimeoutException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -60,6 +65,8 @@
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;

import javax.ws.rs.ProcessingException;

public class DatafeedServiceV1Test {

private DatafeedServiceV1 datafeedService;
Expand Down Expand Up @@ -167,6 +174,16 @@ void startTestFailedAuthRead() throws ApiException, AuthUnauthorizedException {
verify(datafeedApi, times(1)).v4DatafeedIdReadGet("test-id", "1234", "1234", null);
}

@Test
void startTestFailedSocketTimeoutRead() throws ApiException, AuthUnauthorizedException {
when(datafeedApi.v4DatafeedCreatePost("1234", "1234")).thenReturn(new Datafeed().id("test-id"));
when(datafeedApi.v4DatafeedIdReadGet("test-id", "1234", "1234", null))
.thenThrow(new ProcessingException(new SocketTimeoutException()));

this.datafeedService.start();
verify(datafeedApi, times(2)).v4DatafeedIdReadGet("test-id", "1234", "1234", null);
}

@Test
void startServiceAlreadyStarted() throws ApiException, AuthUnauthorizedException {
AtomicInteger signal = new AtomicInteger(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.symphony.bdk.core.service.datafeed.impl;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.symphony.bdk.core.api.invoker.ApiException;
import com.symphony.bdk.core.auth.AuthSession;
import com.symphony.bdk.core.auth.exception.AuthUnauthorizedException;
Expand All @@ -11,19 +19,25 @@
import com.symphony.bdk.core.config.model.BdkRetryConfig;
import com.symphony.bdk.core.service.datafeed.RealTimeEventListener;
import com.symphony.bdk.gen.api.DatafeedApi;
import com.symphony.bdk.gen.api.model.*;
import com.symphony.bdk.gen.api.model.AckId;
import com.symphony.bdk.gen.api.model.V4Event;
import com.symphony.bdk.gen.api.model.V4Initiator;
import com.symphony.bdk.gen.api.model.V4MessageSent;
import com.symphony.bdk.gen.api.model.V4Payload;
import com.symphony.bdk.gen.api.model.V5Datafeed;
import com.symphony.bdk.gen.api.model.V5EventList;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.*;
import javax.ws.rs.ProcessingException;

public class DatafeedServiceV2Test {

Expand Down Expand Up @@ -223,6 +237,17 @@ void testStartClientErrorReadDatafeed() throws ApiException, AuthUnauthorizedExc
verify(datafeedApi, times(1)).deleteDatafeed("test-id", "1234", "1234");
}

@Test
void testStartSocketTimeoutReadDatafeed() throws ApiException, AuthUnauthorizedException {
AckId ackId = datafeedService.getAckId();
when(datafeedApi.listDatafeed("1234", "1234")).thenReturn(Collections.singletonList(new V5Datafeed().id("test-id")));
when(datafeedApi.readDatafeed("test-id", "1234", "1234", ackId)).thenThrow(new ProcessingException(new SocketTimeoutException()));

this.datafeedService.start();
verify(datafeedApi, times(1)).listDatafeed("1234", "1234");
verify(datafeedApi, times(2)).readDatafeed("test-id", "1234", "1234", ackId);
}

@Test
void testStartAuthErrorReadDatafeed() throws ApiException, AuthUnauthorizedException {
AckId ackId = datafeedService.getAckId();
Expand Down
2 changes: 1 addition & 1 deletion symphony-bdk-examples/bdk-core-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>symphony-bdk-examples</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1.BETA</version>
</parent>

<artifactId>symphony-bdk-core-examples</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions symphony-bdk-examples/bdk-spring-boot-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>symphony-bdk-examples</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1.BETA</version>
</parent>

<artifactId>symphony-bdk-spring-boot-examples</artifactId>
Expand All @@ -33,4 +33,4 @@
</dependency>
</dependencies>

</project>
</project>
2 changes: 1 addition & 1 deletion symphony-bdk-examples/bdk-template-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>symphony-bdk-examples</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1.BETA</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
3 changes: 2 additions & 1 deletion symphony-bdk-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<parent>
<artifactId>symphony-bdk-java</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</parent>

<artifactId>symphony-bdk-examples</artifactId>
<version>1.2.1.BETA</version>
<name>Symphony Java BDK Examples Parent</name>
<description>Symphony Java BDK Parent Module</description>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion symphony-bdk-legacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-java</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</parent>

<artifactId>symphony-bdk-legacy</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion symphony-bdk-legacy/sms-sdk-renderer-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-legacy</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</parent>

<artifactId>sms-sdk-renderer-java</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion symphony-bdk-legacy/symphony-api-client-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-legacy</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</parent>

<artifactId>symphony-api-client-java</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion symphony-bdk-legacy/symphony-bdk-bot-sdk-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.symphony.platformsolutions</groupId>
<artifactId>symphony-bdk-legacy</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.0</version>
</parent>

<artifactId>symphony-bdk-bot-sdk-java</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ public interface InternalEventListener {
/**
* Connection request received. Pushes event to EventDispatcher.
*
* @param event
* @param connectionRequestedEvent
*/
void onConnectionRequested(ConnectionRequestedEvent connectionRequestedEvent);

/**
* Accepted connection request event received. Pushes event to EventDispatcher.
*
* @param event
* @param connectionAcceptedEvent
*/
void onConnectionAccepted(ConnectionAcceptedEvent connectionRequestedEvent);
void onConnectionAccepted(ConnectionAcceptedEvent connectionAcceptedEvent);

}
4 changes: 2 additions & 2 deletions symphony-bdk-spring/bdk-core-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>symphony-bdk-spring</artifactId>
<groupId>com.symphony.platformsolutions</groupId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.1.BETA</version>
</parent>

<artifactId>symphony-bdk-core-spring-boot-starter</artifactId>
Expand Down Expand Up @@ -57,4 +57,4 @@

</dependencies>

</project>
</project>
Loading