2019-09-20 15:20:40 +02:00
package org.gcube.vremanagement.executor.client ;
2019-09-24 14:59:43 +02:00
import java.io.IOException ;
import java.util.List ;
import org.gcube.vremanagement.executor.json.SEMapper ;
import org.gcube.vremanagement.executor.plugin.PluginDeclaration ;
2019-09-20 15:20:40 +02:00
import org.junit.Assert ;
import org.junit.Test ;
2019-09-24 14:59:43 +02:00
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import com.fasterxml.jackson.core.JsonParseException ;
import com.fasterxml.jackson.databind.JsonMappingException ;
2019-09-20 15:20:40 +02:00
/ * *
* @author Luca Frosini ( ISTI - CNR )
* /
public class SmartExecutorClientTest {
2019-09-24 14:59:43 +02:00
private static Logger logger = LoggerFactory . getLogger ( SmartExecutorClientTest . class ) ;
2019-09-20 15:20:40 +02:00
public static final String HTTP_ADDRESS = " http://smartexecutor.d4science.org:8090/smart-executor/rest " ;
public static final String HTTPS_ADDRESS = " https://smartexecutor.d4science.org:8090/smart-executor/rest " ;
public static final String HOST = " smartexecutor.d4science.org " ;
@Test
public void testSetAddress ( ) {
SmartExecutorClientImpl smartExecutorClient = new SmartExecutorClientImpl ( ) ;
smartExecutorClient . setAddress ( HTTP_ADDRESS ) ;
Assert . assertTrue ( smartExecutorClient . getAddress ( ) . compareTo ( HTTP_ADDRESS ) = = 0 ) ;
Assert . assertTrue ( smartExecutorClient . getHost ( ) . compareTo ( HOST ) = = 0 ) ;
smartExecutorClient . setAddress ( HTTPS_ADDRESS ) ;
Assert . assertTrue ( smartExecutorClient . getAddress ( ) . compareTo ( HTTPS_ADDRESS ) = = 0 ) ;
Assert . assertTrue ( smartExecutorClient . getHost ( ) . compareTo ( HOST ) = = 0 ) ;
}
2019-09-24 14:59:43 +02:00
@Test
public void testUnmarshallPluginList ( ) throws JsonParseException , JsonMappingException , IOException {
String pluginList = " [{ \" @class \" : \" PluginDeclaration \" , \" description \" : \" Hello World Description \" , \" supportedCapabilities \" :{ \" FakeKey \" : \" FakeValue \" }, \" version \" : \" 1.1.2 \" , \" name \" : \" HelloWorld \" }] " ;
List < PluginDeclaration > list = SEMapper . getInstance ( ) . unmarshalList ( PluginDeclaration . class , pluginList ) ;
logger . debug ( " {} " , SEMapper . getInstance ( ) . marshal ( PluginDeclaration . class , list ) ) ;
}
2019-09-20 15:20:40 +02:00
}