Skip to content

Commit b3f40d9

Browse files
committed
adding integ tests for S3Control to get better coverage for inconsistent exception unmarshalling
1 parent f1a7fad commit b3f40d9

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3ControlIntegrationTest.java

+37-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import static org.assertj.core.api.Assertions.assertThat;
1818
import static org.assertj.core.api.Fail.fail;
19-
import static org.junit.Assert.assertEquals;
2019
import static org.junit.Assert.assertNotNull;
2120
import static org.junit.Assert.assertTrue;
2221

@@ -86,7 +85,7 @@ public void putPublicAccessBlock_NoSuchAccount() {
8685
.publicAccessBlockConfiguration(r2 -> r2.restrictPublicBuckets(true))));
8786
fail("Expected exception");
8887
} catch (S3ControlException e) {
89-
assertEquals("AccessDenied", e.awsErrorDetails().errorCode());
88+
assertThat(e.awsErrorDetails().errorCode()).isEqualTo("AccessDenied");
9089
assertNotNull(e.requestId());
9190
}
9291
}
@@ -97,7 +96,41 @@ public void getPublicAccessBlock_NoSuchAccount() {
9796
client.getPublicAccessBlock(r -> r.accountId(INVALID_ACCOUNT_ID));
9897
fail("Expected exception");
9998
} catch (S3ControlException e) {
100-
assertEquals("AccessDenied", e.awsErrorDetails().errorCode());
99+
assertThat(e.awsErrorDetails().errorCode()).isEqualTo("AccessDenied");
100+
assertNotNull(e.requestId());
101+
}
102+
}
103+
104+
@Test
105+
public void getPublicAccessBlock_NoSuchPublicAccessBlock() {
106+
try {
107+
client.getPublicAccessBlock(r -> r.accountId(accountId));
108+
fail("Expected exception");
109+
} catch (S3ControlException e) {
110+
assertThat(e.awsErrorDetails().errorCode()).isEqualTo("NoSuchPublicAccessBlockConfiguration");
111+
assertThat(e).isInstanceOf(NoSuchPublicAccessBlockConfigurationException.class);
112+
assertNotNull(e.requestId());
113+
}
114+
}
115+
116+
@Test
117+
public void listJobs_InvalidRequest() {
118+
try {
119+
client.listJobs(r -> r.accountId(accountId).jobStatusesWithStrings("test"));
120+
fail("Expected exception");
121+
} catch (S3ControlException e) {
122+
assertThat(e.awsErrorDetails().errorCode()).isEqualTo("InvalidRequest");
123+
assertNotNull(e.requestId());
124+
}
125+
}
126+
127+
@Test
128+
public void describeJob_InvalidRequest() {
129+
try {
130+
client.describeJob(r -> r.accountId(accountId).jobId("someid"));
131+
fail("Expected exception");
132+
} catch (S3ControlException e) {
133+
assertThat(e.awsErrorDetails().errorCode()).isEqualTo("InvalidRequest");
101134
assertNotNull(e.requestId());
102135
}
103136
}
@@ -108,7 +141,7 @@ public void deletePublicAccessBlock_NoSuchAccount() {
108141
client.deletePublicAccessBlock(r -> r.accountId(INVALID_ACCOUNT_ID));
109142
fail("Expected exception");
110143
} catch (S3ControlException e) {
111-
assertEquals("AccessDenied", e.awsErrorDetails().errorCode());
144+
assertThat(e.awsErrorDetails().errorCode()).isEqualTo("AccessDenied");
112145
assertNotNull(e.requestId());
113146
}
114147
}

0 commit comments

Comments
 (0)