import static org.assertj.core.api.Assertions.assertThat;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.junit.Test;
import org.web3j.abi.datatypes.Bool;

import com.hshnordbank.ssd.wrapper.SSDRegistry;
import com.hshnordbank.web3j.SSDRegistryHelper;
import com.hshnordbank.web3j.example.DeploymentExample;
import com.uzh.csg.overlaynetworks.web3j.AsyncHelper;
import com.uzh.csg.overlaynetworks.web3j.IsContractDeployedExample;
import com.uzh.csg.overlaynetworks.web3j.MessageRegistryHelper;
import com.uzh.csg.overlaynetworks.wrappers.MessageRegistry;

public class IsContractDeployedExampleTest extends AbstractLocalhostTest{
	
	private static final Logger LOGGER = Logger.getLogger(CanGetValuesTest.class.getName() );

    @Test
    public void shouldReturnTrueIfContractIsDeployed() throws InterruptedException, ExecutionException {
    	
    	try{    		
    		
    	final String contractAddress = run(new IsContractDeployedExample());
        final MessageRegistry messageRegistry = MessageRegistryHelper.getMessageRegistry(getWeb3j(), contractAddress); 
        
        final Future<Bool> asyncResult = messageRegistry.isDeployed();
        final boolean isDeployed = AsyncHelper.waitForResult(asyncResult).getValue();
        

		LOGGER.log(Level.INFO, this.getClass().toString()+"[messageRegistry.isDeployed="+isDeployed+"]");
        assertThat(isDeployed).isTrue();
        
    	} catch(Exception e){
    		LOGGER.log(Level.INFO, e.toString()+"["+e.getClass().toString()+"]");
    	}

    }
}
@@ -956,31 +956,8 @@
   %09%0A
-    %09try%7B    %09%09%0A    %09%09%0A
     
@@ -1158,42 +1158,20 @@
     
-%0A        final Future%3CBool%3E asyncR
+final Bool r
 esul
@@ -1206,92 +1206,12 @@
 ed()
-;%0A        final boolean isDeployed = AsyncHelper.waitForResult(asyncResult).getValue
+.get
 ();%0A
@@ -1219,17 +1219,16 @@
        %0A
-%0A
 %09%09LOGGER
@@ -1302,26 +1302,33 @@
 loyed=%22+
-isDeployed
+result.getValue()
 +%22%5D%22);%0A 
@@ -1349,149 +1349,41 @@
 hat(
-isDeployed).isTrue();%0A        %0A    %09%7D catch(Exception e)%7B%0A    %09%09LOGGER.log(Level.INFO, e.toString()+%22%5B%22+e.getClass().toString()+%22%5D%22
+result.getValue()).isTrue(
 );%0A    
-%09%7D%0A
 %0A   

Clean up test