Source:
<code>public void testSecretOperations() throws Exception { requireDockerApiVersionAtLeast("1.25", "secret support"); for (final Secret secret : sut.listSecrets()) { sut.deleteSecret(secret.id()); } assertThat(sut.listSecrets().size(), equalTo(0)); final String secretData = Base64.encodeAsString("testdata".getBytes()); final Map<String, String> labels = ImmutableMap.of("foo", "bar", "1", "a"); final SecretSpec secretSpec = SecretSpec.builder() .name("asecret") .data(secretData) .labels(labels) .build(); final SecretCreateResponse response = sut.createSecret(secretSpec); final String secretId = response.id(); assertThat(secretId, is(notNullValue())); final SecretSpec secretSpecConflict = SecretSpec.builder() .name("asecret") .data(secretData) .labels(labels) .build(); try { sut.createSecret(secretSpecConflict); fail("Should fail due to secret name conflict"); <START> } catch (DockerException ex) { <END> } final SecretSpec secretSpecInvalidData = SecretSpec.builder() .name("asecret2") .data("plainData") .labels(labels) .build(); try { sut.createSecret(secretSpecInvalidData); fail("Should fail due to non base64 data"); } catch (DockerException ex) { } final Secret secret = sut.inspectSecret(secretId); final List<Secret> secrets = sut.listSecrets(); assertThat(secrets.size(), equalTo(1)); assertThat(secrets, hasItem(secret)); sut.deleteSecret(secretId); assertThat(sut.listSecrets().size(), equalTo(0)); try { sut.inspectSecret(secretId); fail("Should fail because of non-existant secret ID"); } catch (DockerException ex) { } try { sut.deleteSecret(secretId); fail("Should fail because of non-existant secret ID"); } catch (DockerException ex) { } }</code><technical_language>This ConflictException</technical_language>

Target:
public void testSecretOperations() throws Exception { requireDockerApiVersionAtLeast("1.25", "secret support"); for (final Secret secret : sut.listSecrets()) { sut.deleteSecret(secret.id()); } assertThat(sut.listSecrets().size(), equalTo(0)); final String secretData = Base64.encodeAsString("testdata".getBytes()); final Map<String, String> labels = ImmutableMap.of("foo", "bar", "1", "a"); final SecretSpec secretSpec = SecretSpec.builder() .name("asecret") .data(secretData) .labels(labels) .build(); final SecretCreateResponse response = sut.createSecret(secretSpec); final String secretId = response.id(); assertThat(secretId, is(notNullValue())); final SecretSpec secretSpecConflict = SecretSpec.builder() .name("asecret") .data(secretData) .labels(labels) .build(); try { sut.createSecret(secretSpecConflict); fail("Should fail due to secret name conflict"); } catch (DockerRequestException ex) { } final SecretSpec secretSpecInvalidData = SecretSpec.builder() .name("asecret2") .data("plainData") .labels(labels) .build(); try { sut.createSecret(secretSpecInvalidData); fail("Should fail due to non base64 data"); } catch (DockerException ex) { } final Secret secret = sut.inspectSecret(secretId); final List<Secret> secrets = sut.listSecrets(); assertThat(secrets.size(), equalTo(1)); assertThat(secrets, hasItem(secret)); sut.deleteSecret(secretId); assertThat(sut.listSecrets().size(), equalTo(0)); try { sut.inspectSecret(secretId); fail("Should fail because of non-existant secret ID"); } catch (NotFoundException ex) { } try { sut.deleteSecret(secretId); fail("Should fail because of non-existant secret ID"); } catch (DockerRequestException ex) { } }