diff --git a/sdk/src/main/java/com/silanis/esl/sdk/examples/SignableOptionalSignaturesExample.java b/sdk/src/main/java/com/silanis/esl/sdk/examples/SignableOptionalSignaturesExample.java deleted file mode 100644 index 96c19b841..000000000 --- a/sdk/src/main/java/com/silanis/esl/sdk/examples/SignableOptionalSignaturesExample.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.silanis.esl.sdk.examples; - -import com.silanis.esl.sdk.DocumentPackage; -import com.silanis.esl.sdk.DocumentType; -import com.silanis.esl.sdk.Signature; - -import java.util.List; - -import static com.silanis.esl.sdk.builder.DocumentBuilder.newDocumentWithName; -import static com.silanis.esl.sdk.builder.PackageBuilder.newPackageNamed; -import static com.silanis.esl.sdk.builder.SignatureBuilder.signatureFor; -import static com.silanis.esl.sdk.builder.SignerBuilder.newSignerWithEmail; - -public class SignableOptionalSignaturesExample extends SDKSample { - - private DocumentPackage sentPackage; - - private String signer1Id = "signer1Id"; - private String signer2Id = "signer2Id"; - private String documentId = "documentId"; - - public List signer1SignableSignatures, signer2SignableSignatures; - - public static void main( String... args ) { - new SignableOptionalSignaturesExample().run(); - } - - public void execute() { - DocumentPackage superDuperPackage = newPackageNamed(getPackageName()) - .describedAs("This is a package created using the eSignLive SDK") - .withSigner(newSignerWithEmail(email1) - .withFirstName("John1") - .withLastName("Smith1") - .withCustomId(signer1Id)) - .withSigner(newSignerWithEmail(email2) - .withFirstName("John2") - .withLastName("Smith2") - .withCustomId(signer2Id)) - .withDocument(newDocumentWithName("First Document") - .fromStream(documentInputStream1, DocumentType.PDF) - .withId(documentId) - .withSignature(signatureFor(email1) - .onPage(0) - .atPosition(100, 100)) - .withSignature(signatureFor(email1) - .onPage(0) - .atPosition(300, 100)) - .withSignature(signatureFor(email2) - .onPage(0) - .atPosition(500, 100)) - .withSignature(signatureFor(email2) - .onPage(0) - .atPosition(700, 100) - .makeOptional())) - .build(); - - packageId = eslClient.createPackage( superDuperPackage ); - eslClient.sendPackage( packageId ); - sentPackage = eslClient.getPackage( packageId ); - signer1SignableSignatures = eslClient.getApprovalService().getAllSignableSignatures(sentPackage, documentId, signer1Id); - signer2SignableSignatures = eslClient.getApprovalService().getAllSignableSignatures(sentPackage, documentId, signer2Id); - } -} diff --git a/tester/src/test/java/com/silanis/esl/sdk/examples/OptionalSignaturesExampleTest.java b/tester/src/test/java/com/silanis/esl/sdk/examples/OptionalSignaturesExampleTest.java index 6ecc2df0e..56ff250eb 100644 --- a/tester/src/test/java/com/silanis/esl/sdk/examples/OptionalSignaturesExampleTest.java +++ b/tester/src/test/java/com/silanis/esl/sdk/examples/OptionalSignaturesExampleTest.java @@ -3,7 +3,10 @@ import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class OptionalSignaturesExampleTest { @@ -12,13 +15,18 @@ public void verifyResult() { OptionalSignaturesExample example = new OptionalSignaturesExample(); example.run(); - assertThat("signer1's signable signatures are not set correctly. ", example.signer1SignableSignatures.size(), hasSize(2)); + assertThat("signer1's signable signatures are not set correctly. ", example.signer1SignableSignatures, hasSize(2)); assertThat("signer1's signable signature1 is not set correctly. ", example.signer1SignableSignatures.get(0).getSignerEmail(), is(example.email1)); assertThat("signer1's signable signature2 is not set correctly. ", example.signer1SignableSignatures.get(1).getSignerEmail(), is(example.email1)); - assertThat("signer2's signable signatures are not set correctly. ", example.signer2SignableSignatures.size(), hasSize(2)); + assertThat("signer2's signable signatures are not set correctly. ", example.signer2SignableSignatures, hasSize(2)); assertThat("signer2's signable signature1 is not set correctly. ", example.signer2SignableSignatures.get(0).getSignerEmail(), is(example.email2)); assertThat("signer2's signable signature2 is not set correctly. ", example.signer2SignableSignatures.get(1).getSignerEmail(), is(example.email2)); - assertTrue("signer2's signable signature2 is not optional. ", example.signer2SignableSignatures.get(1).isOptional()); + + if(example.signer2SignableSignatures.get(0).isOptional()) { + assertFalse("signer2's signable signature2 is not optional. ", example.signer2SignableSignatures.get(1).isOptional()); + } else { + assertTrue("signer2's signable signature2 is not optional. ", example.signer2SignableSignatures.get(1).isOptional()); + } } } diff --git a/tester/src/test/java/com/silanis/esl/sdk/examples/SignableOptionalSignaturesExampleTest.java b/tester/src/test/java/com/silanis/esl/sdk/examples/SignableOptionalSignaturesExampleTest.java deleted file mode 100644 index 73b34e9a7..000000000 --- a/tester/src/test/java/com/silanis/esl/sdk/examples/SignableOptionalSignaturesExampleTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.silanis.esl.sdk.examples; - -import org.junit.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -public class SignableOptionalSignaturesExampleTest { - - @Test - public void verifyResult() { - SignableOptionalSignaturesExample example = new SignableOptionalSignaturesExample(); - example.run(); - - assertThat("signer1's signable signatures are not set correctly. ", example.signer1SignableSignatures.size(), is(2)); - assertThat("signer1's signable signature1 is not set correctly. ", example.signer1SignableSignatures.get(0).getSignerEmail(), is(example.email1)); - assertThat("signer1's signable signature2 is not set correctly. ", example.signer1SignableSignatures.get(1).getSignerEmail(), is(example.email1)); - - assertThat("signer2's signable signatures are not set correctly. ", example.signer2SignableSignatures.size(), is(2)); - assertThat("signer2's signable signature1 is not set correctly. ", example.signer2SignableSignatures.get(0).getSignerEmail(), is(example.email2)); - assertThat("signer2's signable signature2 is not set correctly. ", example.signer2SignableSignatures.get(1).getSignerEmail(), is(example.email2)); - assertThat("signer2's signable signature2 is not optional. ", example.signer2SignableSignatures.get(1).isOptional(), is(true)); - } -}