1515import java .security .KeyPair ;
1616import java .security .KeyPairGenerator ;
1717import java .security .PrivateKey ;
18+ import java .util .HashSet ;
19+ import java .util .Set ;
1820
1921import com .adobe .aio .auth .Context ;
22+ import com .adobe .aio .auth .OAuthContext ;
2023import com .adobe .aio .util .Constants ;
2124import org .junit .jupiter .api .BeforeAll ;
2225import org .junit .jupiter .api .Test ;
@@ -38,22 +41,16 @@ public static void beforeClass() throws Exception {
3841
3942 @ Test
4043 public void successFullBuilder () throws IOException {
41-
42- class MockContext implements Context {
43- @ Override
44- public void validate () {
45-
46- }
47- }
48-
44+ Set <String > scopes = new HashSet <>();
45+ scopes .add ("scope1" );
4946 Workspace actual = Workspace .builder ()
5047 .imsUrl (Constants .PROD_IMS_URL )
5148 .imsOrgId (Workspace .IMS_ORG_ID + TEST_VALUE )
5249 .apiKey (Workspace .API_KEY + TEST_VALUE )
5350 .consumerOrgId (Workspace .CONSUMER_ORG_ID + TEST_VALUE )
5451 .projectId (Workspace .PROJECT_ID + TEST_VALUE )
5552 .workspaceId (Workspace .WORKSPACE_ID + TEST_VALUE )
56- .authContext (new MockContext ( ))
53+ .authContext (new OAuthContext ( "someClientSecret" , scopes ))
5754 .build ();
5855
5956 assertEquals (Workspace .IMS_ORG_ID + TEST_VALUE , actual .getImsOrgId ());
@@ -63,6 +60,21 @@ public void validate() {
6360 assertEquals (Workspace .WORKSPACE_ID + TEST_VALUE , actual .getWorkspaceId ());
6461 assertEquals (Constants .PROD_IMS_URL , actual .getImsUrl ());
6562 actual .validateWorkspaceContext ();
63+ actual .validateAll ();
64+ }
65+
66+ @ Test
67+ public void missingApiKey () {
68+ Workspace actual = Workspace .builder ()
69+ .imsUrl (Constants .PROD_IMS_URL )
70+ .imsOrgId (Workspace .IMS_ORG_ID + TEST_VALUE )
71+ .consumerOrgId (Workspace .CONSUMER_ORG_ID + TEST_VALUE )
72+ .projectId (Workspace .PROJECT_ID + TEST_VALUE )
73+ .workspaceId (Workspace .WORKSPACE_ID + TEST_VALUE )
74+ .build ();
75+ actual .validateWorkspaceContext ();
76+ Exception ex = assertThrows (IllegalStateException .class , actual ::validateAll );
77+ assertEquals ("Your `Workspace` is missing an apiKey" , ex .getMessage ());
6678 }
6779
6880 @ Test
@@ -81,16 +93,6 @@ public void missingConsumerOrgId() {
8193 assertEquals ("Your `Workspace` is missing a consumerOrgId" , ex .getMessage ());
8294 }
8395
84- @ Test
85- public void missingApiKey () {
86- Workspace actual = Workspace .builder ()
87- .imsOrgId (Workspace .IMS_ORG_ID + TEST_VALUE )
88- .consumerOrgId (Workspace .CONSUMER_ORG_ID + TEST_VALUE )
89- .build ();
90- Exception ex = assertThrows (IllegalStateException .class , actual ::validateWorkspaceContext );
91- assertEquals ("Your `Workspace` is missing an apiKey" , ex .getMessage ());
92- }
93-
9496 @ Test
9597 public void missingProjectId () {
9698 Workspace actual = Workspace .builder ()
0 commit comments