1818
1919import static com .google .common .truth .Truth .assertThat ;
2020import static com .google .common .truth .Truth .assertWithMessage ;
21+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
2122
2223import com .google .cloud .compute .v1 .Operation ;
24+ import com .google .cloud .compute .v1 .ResourcePolicy ;
2325import java .io .IOException ;
2426import java .util .UUID ;
2527import java .util .concurrent .ExecutionException ;
2628import java .util .concurrent .TimeUnit ;
2729import java .util .concurrent .TimeoutException ;
28- import org .junit .jupiter .api .AfterAll ;
2930import org .junit .jupiter .api .BeforeAll ;
31+ import org .junit .jupiter .api .MethodOrderer ;
32+ import org .junit .jupiter .api .Order ;
3033import org .junit .jupiter .api .Test ;
34+ import org .junit .jupiter .api .TestMethodOrder ;
3135import org .junit .jupiter .api .Timeout ;
3236import org .junit .runner .RunWith ;
3337import org .junit .runners .JUnit4 ;
3438
3539@ RunWith (JUnit4 .class )
3640@ Timeout (value = 6 , unit = TimeUnit .MINUTES )
41+ @ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
3742public class SnapshotIT {
3843 private static final String PROJECT_ID = System .getenv ("GOOGLE_CLOUD_PROJECT" );
3944 private static final String ZONE = "asia-south1-a" ;
@@ -58,22 +63,33 @@ public static void setUp()
5863 requireEnvVar ("GOOGLE_CLOUD_PROJECT" );
5964 }
6065
61- @ AfterAll
62- public static void cleanup ()
66+ @ Test
67+ @ Order (1 )
68+ public void testCreateSnapshotScheduleHourly ()
6369 throws IOException , ExecutionException , InterruptedException , TimeoutException {
64- // Delete snapshot schedule created for testing.
65- Operation . Status status = DeleteSnapshotSchedule
66- . deleteSnapshotSchedule ( PROJECT_ID , REGION , SCHEDULE_NAME );
70+ Operation . Status status = CreateSnapshotSchedule . createSnapshotSchedule (
71+ PROJECT_ID , REGION , SCHEDULE_NAME , SCHEDULE_DESCRIPTION ,
72+ MAX_RETENTION_DAYS , STORAGE_LOCATION , ON_SOURCE_DISK_DELETE );
6773
6874 assertThat (status ).isEqualTo (Operation .Status .DONE );
6975 }
7076
7177 @ Test
72- public void testCreateSnapshotScheduleHourly ()
78+ @ Order (2 )
79+ public void testGetSnapshotSchedule () throws IOException {
80+
81+ ResourcePolicy resourcePolicy = GetSnapshotSchedule .getSnapshotSchedule (
82+ PROJECT_ID , REGION , SCHEDULE_NAME );
83+ assertNotNull (resourcePolicy );
84+ assertThat (resourcePolicy .getName ()).isEqualTo (SCHEDULE_NAME );
85+ }
86+
87+ @ Test
88+ @ Order (3 )
89+ public void testDeleteSnapshotSchedule ()
7390 throws IOException , ExecutionException , InterruptedException , TimeoutException {
74- Operation .Status status = CreateSnapshotSchedule .createSnapshotSchedule (
75- PROJECT_ID , REGION , SCHEDULE_NAME , SCHEDULE_DESCRIPTION ,
76- MAX_RETENTION_DAYS , STORAGE_LOCATION , ON_SOURCE_DISK_DELETE );
91+ Operation .Status status = DeleteSnapshotSchedule
92+ .deleteSnapshotSchedule (PROJECT_ID , REGION , SCHEDULE_NAME );
7793
7894 assertThat (status ).isEqualTo (Operation .Status .DONE );
7995 }
0 commit comments