EchoSignSignatureServiceImpl implements EchoSignSignatureService { @Override public EmbeddedWidgetCreationResult createEmbeddedWidget( byte[] documentBytes, String documentFileName, String documentName, String signedDocumentUrl, String email) { Assert.notNull(documentBytes, "Document bytes must not be null."); Assert.hasText(documentFileName, "Document file name must not be null or empty."); FileInfo fileInfo = new FileInfo(); fileInfo.setFileName(documentFileName); fileInfo.setFile(documentBytes); ArrayOfFileInfo fileInfos = new ArrayOfFileInfo(); fileInfos.getFileInfo().add(fileInfo); WidgetCreationInfo widgetInfo = new WidgetCreationInfo(); if (!StringUtils.hasText(documentName)) { documentName = documentFileName; } widgetInfo.setName(documentName); if (StringUtils.hasText(signedDocumentUrl)) { CallbackInfo callbackInfo = new CallbackInfo(); widgetInfo.setCallbackInfo(callbackInfo); } widgetInfo.setFileInfos(fileInfos); widgetInfo .setSignatureFlow(SignatureFlow.SENDER_SIGNATURE_NOT_REQUIRED); WidgetPersonalizationInfo personalizationInfo = new WidgetPersonalizationInfo(); personalizationInfo.setReusable(false); personalizationInfo.setEmail(email); EmbeddedWidgetCreationResult embeddedWidgetCreationResult = getCachedService() .createPersonalEmbeddedWidget(echoSignApiKey, null, widgetInfo, personalizationInfo); return embeddedWidgetCreationResult; } EchoSignSignatureServiceImpl(String echoSignServiceUrl,
			String echoSignApiKey); @Override String sendDocumentToSign(byte[] documentBytes,
			String documentFileName, String documentName,
			String recipientEmail, String messageToRecipient); @Override String sendDocumentToSign(byte[] documentBytes,
			String documentFileName, String documentName,
			String recipientEmail, String messageToRecipient,
			String signedDocumentUrl); @Override DocumentInfo getDocumentInfo(String documentKey); @Override byte[] getLatestDocument(String documentKey); @Override String getChildDocumentKey(String documentKey); Pong testPing(); byte[] testEchoFile(byte[] input); @Override EmbeddedWidgetCreationResult createEmbeddedWidget(
			byte[] documentBytes, String documentFileName, String documentName,
			String signedDocumentUrl, String email);  }
@Test public void testCreateEmbeddedWidget() { sut.createEmbeddedWidget(DOCUMENT_BYTES, DOCUMENT_FILE_NAME, DOCUMENT_NAME, SIGNED_DOCUMENT_URL, EMAIL); verify(service).createPersonalEmbeddedWidget(eq("echoSignApiKey"), isNull(SenderInfo.class), any(WidgetCreationInfo.class), any(WidgetPersonalizationInfo.class)); }
@Test(expected=IllegalArgumentException.class) public void testCreateEmbeddedWidget_when_file_name_is_null() { sut.createEmbeddedWidget(DOCUMENT_BYTES, null, DOCUMENT_NAME, SIGNED_DOCUMENT_URL, EMAIL); }
@Test(expected=IllegalArgumentException.class) public void testCreateEmbeddedWidget_when_file_document_byte_is_null() { sut.createEmbeddedWidget(null, DOCUMENT_FILE_NAME, DOCUMENT_NAME, SIGNED_DOCUMENT_URL, EMAIL); }