forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
114 additions
and
0 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
javav2/example_code/stepfunctions/src/test/java/StepFunctionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import com.example.stepfunctions.*; | ||
import org.junit.jupiter.api.*; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import software.amazon.awssdk.regions.Region; | ||
import software.amazon.awssdk.services.sfn.SfnClient; | ||
import java.io.*; | ||
import java.util.*; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_METHOD) | ||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
public class StepFunctionsTest { | ||
|
||
private static SfnClient sfnClient; | ||
private static String stateMachineArn = ""; // gets dynamically set in a test | ||
private static String exeArn = ""; // gets dynamically set in a test | ||
private static String jsonFile = ""; | ||
private static String jsonFileSM = ""; | ||
private static String roleARN = ""; | ||
private static String stateMachineName = ""; | ||
|
||
@BeforeAll | ||
public static void setUp() throws IOException { | ||
|
||
Region region = Region.US_EAST_1; | ||
sfnClient = SfnClient.builder() | ||
.region(region) | ||
.build(); | ||
|
||
try (InputStream input = StepFunctionsTest.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 | ||
jsonFile = prop.getProperty("jsonFile"); | ||
jsonFileSM = prop.getProperty("jsonFileSM"); | ||
roleARN = prop.getProperty("roleARN"); | ||
stateMachineName = prop.getProperty("stateMachineName"); | ||
|
||
|
||
|
||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
|
||
@Test | ||
@Order(1) | ||
public void whenInitializingAWSService_thenNotNull() { | ||
assertNotNull(sfnClient); | ||
System.out.println("Test 1 passed"); | ||
} | ||
|
||
@Test | ||
@Order(2) | ||
public void CreateStateMachine() { | ||
stateMachineArn = CreateStateMachine.createMachine(sfnClient, roleARN, stateMachineName, jsonFileSM); | ||
assertTrue(!stateMachineArn.isEmpty()); | ||
System.out.println("Test 2 passed"); | ||
} | ||
|
||
@Test | ||
@Order(3) | ||
public void StartExecution() { | ||
exeArn = StartExecution.startWorkflow(sfnClient, stateMachineArn, jsonFile); | ||
assertTrue(!stateMachineArn.isEmpty()); | ||
System.out.println("Test 3 passed"); | ||
} | ||
|
||
@Test | ||
@Order(4) | ||
public void ListStateMachines() { | ||
ListStateMachines.listMachines(sfnClient); | ||
System.out.println("Test 4 passed"); | ||
} | ||
|
||
@Test | ||
@Order(5) | ||
public void ListActivities() { | ||
ListActivities.getActivites(sfnClient); | ||
System.out.println("Test 5 passed"); | ||
|
||
} | ||
|
||
|
||
@Test | ||
@Order(6) | ||
public void GetExecutionHistory() { | ||
GetExecutionHistory.getExeHistory(sfnClient,exeArn ); | ||
System.out.println("Test 6 passed"); | ||
} | ||
|
||
@Test | ||
@Order(7) | ||
public void DeleteStateMachine() { | ||
|
||
DeleteStateMachine.deleteMachine(sfnClient, stateMachineArn); | ||
System.out.println("Test 7 passed"); | ||
} | ||
|
||
} |