20
20
import static junit .framework .TestCase .assertNotNull ;
21
21
22
22
import com .google .cloud .dataplex .v1 .AspectType ;
23
- import com .google .cloud .dataplex .v1 .AspectTypeName ;
24
- import com .google .cloud .dataplex .v1 .LocationName ;
25
23
import java .io .IOException ;
26
24
import java .util .ArrayList ;
27
25
import java .util .List ;
33
31
public class AspectTypeIT {
34
32
private static final String ID = UUID .randomUUID ().toString ().substring (0 , 8 );
35
33
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 ;
38
35
private static String expectedAspectType ;
39
36
40
37
private static final String PROJECT_ID = requireProjectIdEnvVar ();
@@ -54,67 +51,63 @@ public static void checkRequirements() {
54
51
@ BeforeClass
55
52
// Set-up code that will be executed before all tests
56
53
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 );
60
54
expectedAspectType =
61
55
String .format (
62
56
"projects/%s/locations/%s/aspectTypes/%s" , PROJECT_ID , LOCATION , aspectTypeId );
63
57
// 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 <>());
65
59
}
66
60
67
61
@ 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 );
70
64
assertThat (aspectTypes .stream ().map (AspectType ::getName )).contains (expectedAspectType );
71
65
}
72
66
73
67
@ 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 );
76
70
assertThat (aspectType .getName ()).isEqualTo (expectedAspectType );
77
71
}
78
72
79
73
@ 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 <>());
82
77
assertThat (aspectType .getName ()).isEqualTo (expectedAspectType );
83
78
}
84
79
85
80
@ Test
86
- public void createAspectType_returnsCreatedAspectType () throws Exception {
81
+ public void testCreateAspectType () throws Exception {
87
82
String aspectTypeIdToCreate = "test-aspect-type" + UUID .randomUUID ().toString ().substring (0 , 8 );
88
- AspectTypeName aspectTypeNameToCreate =
89
- AspectTypeName .of (PROJECT_ID , LOCATION , aspectTypeIdToCreate );
90
83
String expectedAspectTypeToCreate =
91
84
String .format (
92
85
"projects/%s/locations/%s/aspectTypes/%s" , PROJECT_ID , LOCATION , aspectTypeIdToCreate );
93
86
94
87
AspectType aspectType =
95
- CreateAspectType .createAspectType (locationName , aspectTypeIdToCreate , new ArrayList <>());
88
+ CreateAspectType .createAspectType (
89
+ PROJECT_ID , LOCATION , aspectTypeIdToCreate , new ArrayList <>());
96
90
// Clean-up created Aspect Type
97
- DeleteAspectType .deleteAspectType (aspectTypeNameToCreate );
91
+ DeleteAspectType .deleteAspectType (PROJECT_ID , LOCATION , aspectTypeIdToCreate );
98
92
99
93
assertThat (aspectType .getName ()).isEqualTo (expectedAspectTypeToCreate );
100
94
}
101
95
102
96
@ Test
103
- public void deleteAspectType_executesTheCallWithoutException () throws Exception {
97
+ public void testDeleteAspectType () throws Exception {
104
98
String aspectTypeIdToDelete = "test-aspect-type" + UUID .randomUUID ().toString ().substring (0 , 8 );
105
- AspectTypeName aspectTypeNameToDelete =
106
- AspectTypeName .of (PROJECT_ID , LOCATION , aspectTypeIdToDelete );
107
99
// Create Aspect Type to be deleted
108
- CreateAspectType .createAspectType (locationName , aspectTypeIdToDelete , new ArrayList <>());
100
+ CreateAspectType .createAspectType (
101
+ PROJECT_ID , LOCATION , aspectTypeIdToDelete , new ArrayList <>());
109
102
110
103
// No exception means successful call
111
- DeleteAspectType .deleteAspectType (aspectTypeNameToDelete );
104
+ DeleteAspectType .deleteAspectType (PROJECT_ID , LOCATION , aspectTypeIdToDelete );
112
105
}
113
106
114
107
@ AfterClass
115
108
// Clean-up code that will be executed after all tests
116
109
public static void tearDown () throws Exception {
117
110
// Clean-up Aspect Type resource created in setUp()
118
- DeleteAspectType .deleteAspectType (aspectTypeName );
111
+ DeleteAspectType .deleteAspectType (PROJECT_ID , LOCATION , aspectTypeId );
119
112
}
120
113
}
0 commit comments