import com.example.kinesis.CreateDataStream;
import com.example.kinesis.DescribeLimits;
import org.junit.jupiter.api.*;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.kinesis.KinesisClient;
import software.amazon.awssdk.services.kinesis.model.*;
import java.io.*;
import com.example.kinesis.*;
import java.util.*;
import java.util.concurrent.TimeUnit;

@TestInstance(TestInstance.Lifecycle.PER_METHOD)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class KinesisServiceIntegrationTest {

    private static KinesisClient kinesisClient;

    private static String streamName = "";
    private static String existingDataStream = "";

    @BeforeAll
    public static void setUp() throws IOException {

        Region region = Region.US_EAST_1;
        kinesisClient = KinesisClient.builder()
                .region(region)
                .build();
        try (InputStream input = KinesisServiceIntegrationTest.class.getClassLoader().getResourceAsStream("config.properties")) {

            Properties prop = new Properties();

            if (input == null) {
                System.out.println("Sorry, unable to find config.properties");
                return;
            }

            //load a properties file from class path, inside static method
            prop.load(input);

            // Populate the data members required for all tests
            streamName = prop.getProperty("streamName");
            existingDataStream = prop.getProperty("existingDataStream");


        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    @Test
    @Order(1)
    public void whenInitializingKinesisService_thenNotNull() {
        assertNotNull(kinesisClient);
        System.out.println("Test 1 passed");
    }

    @Test
    @Order(2)
    public void CreateDataStream() {

        try {
            CreateDataStream.createStream(kinesisClient, streamName);
        } catch (KinesisException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
        System.out.println("Test 2 passed");
    }

    @Test
    @Order(3)
    public void DescribeLimits() {

        try {
            DescribeLimits.describeKinLimits(kinesisClient);
        } catch (KinesisException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
        System.out.println("Test 3 passed");
    }


    @Test
    @Order(4)
    public void ListShards() {

        try {
            //Wait 60 secs for table to complete
            TimeUnit.SECONDS.sleep(60);
            ListShards.listKinShards(kinesisClient, streamName);
        } catch (KinesisException | InterruptedException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        System.out.println("Test 4 passed");
    }

    @Test
    @Order(5)
    public void PutRecords() {

        try {
            StockTradesWriter.setStockData(kinesisClient, streamName);
        } catch (KinesisException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        System.out.println("Test 5 passed");
    }

    @Test
    @Order(6)
    public void GetRecords() {

        try {
            GetRecords.getStockTrades(kinesisClient, streamName);

        } catch (KinesisException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        System.out.println("Test 6 passed");
    }

    @Test
    @Order(7)
    public void DeleteDataStreem() {

        try {
            DeleteDataStream.deleteStream(kinesisClient, streamName);
        } catch (KinesisException e) {
            System.err.println(e.getMessage());
            System.exit(1);
        }
        System.out.println("Test 7 passed");
    }
}

@@ -113,17 +113,16 @@
 .api.*;%0A
-%0A
 import s
@@ -287,64 +287,8 @@
 nt;%0A
-import software.amazon.awssdk.services.kinesis.model.*;%0A
 impo
@@ -1857,34 +1857,16 @@
 am() %7B%0A%0A
-        try %7B%0A    
         
@@ -1927,153 +1927,8 @@
 e);%0A
-        %7D catch (KinesisException e) %7B%0A            System.err.println(e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A        %7D%0A
     
@@ -2035,34 +2035,16 @@
 ts() %7B%0A%0A
-        try %7B%0A    
         
@@ -2096,153 +2096,8 @@
 t);%0A
-        %7D catch (KinesisException e) %7B%0A            System.err.println(e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A        %7D%0A
     
@@ -2144,17 +2144,16 @@
 %0A    %7D%0A%0A
-%0A
     @Tes
@@ -2389,27 +2389,8 @@
 ch (
-KinesisException %7C 
 Inte
@@ -2605,34 +2605,16 @@
 ds() %7B%0A%0A
-        try %7B%0A    
         
@@ -2676,133 +2676,8 @@
 e);%0A
-        %7D catch (KinesisException e) %7B%0A            System.err.println(e.getMessage());%0A            System.exit(1);%0A        %7D%0A
     
@@ -2780,34 +2780,16 @@
 ds() %7B%0A%0A
-        try %7B%0A    
         
@@ -2845,134 +2845,8 @@
 me);
-%0A%0A        %7D catch (KinesisException e) %7B%0A            System.err.println(e.getMessage());%0A            System.exit(1);%0A        %7D
 %0A   
@@ -2956,34 +2956,16 @@
 em() %7B%0A%0A
-        try %7B%0A    
         
@@ -3026,133 +3026,8 @@
 e);%0A
-        %7D catch (KinesisException e) %7B%0A            System.err.println(e.getMessage());%0A            System.exit(1);%0A        %7D%0A
     

Update KinesisServiceIntegrationTest.java