Skip to content
This repository was archived by the owner on May 26, 2021. It is now read-only.
Open
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
8 changes: 8 additions & 0 deletions DeuStock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@
</systemProperty>
</systemProperties>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
Expand Down
20 changes: 20 additions & 0 deletions DeustockClient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@

</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/*IT</include>
</includes>
<argLine>--enable-preview</argLine>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>doxygen-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public void setParams(HashMap<String, Object> params) {
}

initRoot();

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public void refreshStocks(){
/**
* Method that cleans the stock list and leaves it empty
*/

private void emptyStockList(){
stockLines.clear();
stockList.getChildren().removeIf(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package es.deusto.deustock.client.gateways;

import es.deusto.deustock.client.data.Stock;
import es.deusto.deustock.client.simulation.investment.operations.OperationType;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;
import java.util.List;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;


/**
* Integration test for the functionality between the client and the DeuStock Server
* @author landersanmi
*/
@Tag("integration-resource")
public class DeustockGatewayIT {

private DeustockGateway gateway = new DeustockGateway();

@Test
void testGetStockReturnsNotNull(){
//When
Stock stock = gateway.getStock("BB", "DAILY");
//Then
assertNotNull(stock);
}

@Test
void testGetStockReturnsNull(){
//When
Stock stock = gateway.getStock("BB", "TESTING");
//Then
assertNull(stock);
}

@Test
void testGetSearchedStockReturnsNotNull(){
//When
Stock stock = gateway.getSearchedStock("BB");
//Then
assertNotNull(stock);
}

@Test
void testGetSearchedStockReturnsNull(){
//When
Stock stock = gateway.getSearchedStock("NULL_STOCK");
//Then
assertNull(stock);
}

@Test
void testGetTwitterSentiment(){
//When
double result = gateway.getTwitterSentiment("Happy");
double result2 = gateway.getTwitterSentiment("Angry");
//Then
assertTrue(result>2);
assertTrue(result2<2);
}

@Test
void testGetStockListReturnsNotNull(){
//When
List<Stock> stockList = gateway.getStockList("big");
//Then
assertNotNull(stockList);
}

@Test
void testGetStockListReturnsNull(){
//When
List<Stock> stockList = gateway.getStockList("NULL_LIST_TYPE");
//Then
assertNull(stockList);
}

@Test
void testGetStockReportReturnsNotNull() throws IOException {
//When
File file = gateway.getStockReport("BB", "DAILY", "../");
byte[] file2 = gateway.getStockReport("BB", "DAILY");
//Then
assertNotNull(file);
assertNotNull(file2);
}

@Test
void testResetHoldingsReturnsFalse(){
//When & Then
assertFalse(gateway.resetHoldings("NULL_USER"));
}
@Test
void testGetBalanceReturnsNullPointer(){
//When & Then
assertThrows(NullPointerException.class, () -> gateway.getBalance("NULL_USER"));
}

@Test
void testOpenOperationReturnsIllegalArgumentException(){
assertThrows(IllegalArgumentException.class, () -> gateway.openOperation(null, null, "sdsdsdsdafsdg", 20));
assertThrows(IllegalArgumentException.class, ()-> gateway.openOperation(OperationType.LONG, null, "dhasofdjpiasd", -1));
}

@Test
void testOpenOperationWith0Cuantity(){
assertDoesNotThrow(() -> gateway.openOperation(OperationType.LONG, null, "sdsdsdsdafsdg", 0));
}

@Test
void testOpenOperationReturnsNullPointer(){
assertThrows(NullPointerException.class, () -> gateway.openOperation(OperationType.LONG, null, "fjdsnfsd", 2));
}

@Test
void testCloseOperation(){
assertDoesNotThrow( ()-> gateway.closeOperation("fbndif", "nfdjnagrf"));
}







}