2020import static junit .framework .TestCase .assertNotNull ;
2121
2222import com .google .cloud .dataplex .v1 .AspectType ;
23- import com .google .cloud .dataplex .v1 .AspectTypeName ;
24- import com .google .cloud .dataplex .v1 .LocationName ;
2523import java .io .IOException ;
2624import java .util .ArrayList ;
2725import java .util .List ;
3331public class AspectTypeIT {
3432 private static final String ID = UUID .randomUUID ().toString ().substring (0 , 8 );
3533 private static final String LOCATION = "us-central1" ;
36- private static LocationName locationName ;
37- private static AspectTypeName aspectTypeName ;
34+ private static final String aspectTypeId = "test-aspect-type" + ID ;
3835 private static String expectedAspectType ;
3936
4037 private static final String PROJECT_ID = requireProjectIdEnvVar ();
@@ -54,67 +51,63 @@ public static void checkRequirements() {
5451 @ BeforeClass
5552 // Set-up code that will be executed before all tests
5653 public static void setUp () throws Exception {
57- String aspectTypeId = "test-aspect-type" + ID ;
58- locationName = LocationName .of (PROJECT_ID , LOCATION );
59- aspectTypeName = AspectTypeName .of (PROJECT_ID , LOCATION , aspectTypeId );
6054 expectedAspectType =
6155 String .format (
6256 "projects/%s/locations/%s/aspectTypes/%s" , PROJECT_ID , LOCATION , aspectTypeId );
6357 // Create Aspect Type resource that will be used in tests for "get", "list" and "update" methods
64- CreateAspectType .createAspectType (locationName , aspectTypeId , new ArrayList <>());
58+ CreateAspectType .createAspectType (PROJECT_ID , LOCATION , aspectTypeId , new ArrayList <>());
6559 }
6660
6761 @ Test
68- public void listAspectTypes_returnsListContainingAspectTypeCreatedInSetUp () throws IOException {
69- List <AspectType > aspectTypes = ListAspectTypes .listAspectTypes (locationName );
62+ public void testListAspectTypes () throws IOException {
63+ List <AspectType > aspectTypes = ListAspectTypes .listAspectTypes (PROJECT_ID , LOCATION );
7064 assertThat (aspectTypes .stream ().map (AspectType ::getName )).contains (expectedAspectType );
7165 }
7266
7367 @ Test
74- public void getAspectType_returnsAspectTypeCreatedInSetUp () throws IOException {
75- AspectType aspectType = GetAspectType .getAspectType (aspectTypeName );
68+ public void testGetAspectType () throws IOException {
69+ AspectType aspectType = GetAspectType .getAspectType (PROJECT_ID , LOCATION , aspectTypeId );
7670 assertThat (aspectType .getName ()).isEqualTo (expectedAspectType );
7771 }
7872
7973 @ Test
80- public void updateAspectType_returnsUpdatedAspectType () throws Exception {
81- AspectType aspectType = UpdateAspectType .updateAspectType (aspectTypeName , new ArrayList <>());
74+ public void testUpdateAspectType () throws Exception {
75+ AspectType aspectType =
76+ UpdateAspectType .updateAspectType (PROJECT_ID , LOCATION , aspectTypeId , new ArrayList <>());
8277 assertThat (aspectType .getName ()).isEqualTo (expectedAspectType );
8378 }
8479
8580 @ Test
86- public void createAspectType_returnsCreatedAspectType () throws Exception {
81+ public void testCreateAspectType () throws Exception {
8782 String aspectTypeIdToCreate = "test-aspect-type" + UUID .randomUUID ().toString ().substring (0 , 8 );
88- AspectTypeName aspectTypeNameToCreate =
89- AspectTypeName .of (PROJECT_ID , LOCATION , aspectTypeIdToCreate );
9083 String expectedAspectTypeToCreate =
9184 String .format (
9285 "projects/%s/locations/%s/aspectTypes/%s" , PROJECT_ID , LOCATION , aspectTypeIdToCreate );
9386
9487 AspectType aspectType =
95- CreateAspectType .createAspectType (locationName , aspectTypeIdToCreate , new ArrayList <>());
88+ CreateAspectType .createAspectType (
89+ PROJECT_ID , LOCATION , aspectTypeIdToCreate , new ArrayList <>());
9690 // Clean-up created Aspect Type
97- DeleteAspectType .deleteAspectType (aspectTypeNameToCreate );
91+ DeleteAspectType .deleteAspectType (PROJECT_ID , LOCATION , aspectTypeIdToCreate );
9892
9993 assertThat (aspectType .getName ()).isEqualTo (expectedAspectTypeToCreate );
10094 }
10195
10296 @ Test
103- public void deleteAspectType_executesTheCallWithoutException () throws Exception {
97+ public void testDeleteAspectType () throws Exception {
10498 String aspectTypeIdToDelete = "test-aspect-type" + UUID .randomUUID ().toString ().substring (0 , 8 );
105- AspectTypeName aspectTypeNameToDelete =
106- AspectTypeName .of (PROJECT_ID , LOCATION , aspectTypeIdToDelete );
10799 // Create Aspect Type to be deleted
108- CreateAspectType .createAspectType (locationName , aspectTypeIdToDelete , new ArrayList <>());
100+ CreateAspectType .createAspectType (
101+ PROJECT_ID , LOCATION , aspectTypeIdToDelete , new ArrayList <>());
109102
110103 // No exception means successful call
111- DeleteAspectType .deleteAspectType (aspectTypeNameToDelete );
104+ DeleteAspectType .deleteAspectType (PROJECT_ID , LOCATION , aspectTypeIdToDelete );
112105 }
113106
114107 @ AfterClass
115108 // Clean-up code that will be executed after all tests
116109 public static void tearDown () throws Exception {
117110 // Clean-up Aspect Type resource created in setUp()
118- DeleteAspectType .deleteAspectType (aspectTypeName );
111+ DeleteAspectType .deleteAspectType (PROJECT_ID , LOCATION , aspectTypeId );
119112 }
120113}
0 commit comments