List of usage examples for junit.framework Assert assertNotSame
static public void assertNotSame(Object expected, Object actual)
From source file:pl.edu.pwr.iiar.zak.thermalKit.ThermalDesign.ThermalInstanceTest.java
@Test public void testClone() throws Exception { ThermalInstance instance = new ThermalInstance(); instance.setName("Instance1"); instance.setType(PrimitiveType.SLICEL); ArrayList<Pin> pins = new ArrayList<Pin>(); pins.add(new Pin(false, "D", instance)); pins.add(new Pin(false, "C", instance)); instance.setEnablePins(pins);/*from w ww . ja v a 2 s .c om*/ ArrayList<Attribute> attributes = new ArrayList<Attribute>(); attributes.add(new Attribute("LUT6", "", "value1")); attributes.add(new Attribute("LUT8", "", "value2")); instance.setAttributes(attributes); ThermalInstance newInstance = (ThermalInstance) instance.clone(); newInstance.setName("Instance2"); newInstance.setType(PrimitiveType.SLICEM); newInstance.getEnablePins().get(0).setInstance(newInstance); newInstance.getEnablePins().get(1).setInstance(newInstance); newInstance.getAttributes().get(0).setPhysicalName("LUT1"); newInstance.getAttributes().get(1).setPhysicalName("LUT2"); Assert.assertNotSame(instance.getName(), newInstance.getName()); Assert.assertNotSame(instance.getType(), newInstance.getType()); Assert.assertEquals(instance.getEnablePins().get(0), new Pin(false, "D", instance)); Assert.assertEquals(instance.getEnablePins().get(1), new Pin(false, "C", instance)); Assert.assertEquals(newInstance.getEnablePins().get(0), new Pin(false, "D", newInstance)); Assert.assertEquals(newInstance.getEnablePins().get(1), new Pin(false, "C", newInstance)); Assert.assertEquals(instance.getAttributes().get(0), new Attribute("LUT6", "", "value1")); Assert.assertEquals(instance.getAttributes().get(1), new Attribute("LUT8", "", "value2")); Assert.assertEquals(newInstance.getAttributes().get(0), new Attribute("LUT1", "", "value1")); Assert.assertEquals(newInstance.getAttributes().get(1), new Attribute("LUT2", "", "value2")); }
From source file:SdkUnitTests.java
@Test public void LoginTest() { ApiClient apiClient = new ApiClient(); apiClient.setBasePath(BaseUrl);/*ww w. j a va2s. com*/ String creds = createAuthHeaderCreds(UserName, Password, IntegratorKey); apiClient.addDefaultHeader("X-DocuSign-Authentication", creds); Configuration.setDefaultApiClient(apiClient); try { AuthenticationApi authApi = new AuthenticationApi(); AuthenticationApi.LoginOptions loginOps = authApi.new LoginOptions(); loginOps.setApiPassword("true"); loginOps.setIncludeAccountIdGuid("true"); LoginInformation loginInfo = authApi.login(loginOps); Assert.assertNotSame(null, loginInfo); Assert.assertNotNull(loginInfo.getLoginAccounts()); Assert.assertTrue(loginInfo.getLoginAccounts().size() > 0); List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts(); Assert.assertNotNull(loginAccounts.get(0).getAccountId()); System.out.println("LoginInformation: " + loginInfo); } catch (ApiException ex) { System.out.println("Exception: " + ex); } }
From source file:ma.glasnost.orika.test.converter.PassThroughConverterTestCase.java
@Test public void testPassThroughConverterGenerics2() { /*//w w w. ja v a 2 s. c om * Note: we register the specific Holder<Wrapper<A>> and pass it a Holder<Wrapper<B>>; * we expect that it should not be passed through */ PassThroughConverter ptc = new PassThroughConverter(new TypeBuilder<Holder<Wrapper<A>>>() { }.build()); MapperFactory factory = MappingUtil.getMapperFactory(); factory.getConverterFactory().registerConverter(ptc); B b = new B(); b.setString("Hello"); Holder<B> holder = new Holder<B>(); holder.setHeld(b); Wrapper<Holder<B>> wrapper = new Wrapper<Holder<B>>(); wrapper.setHeld(holder); Type<Wrapper<Holder<B>>> fromType = new TypeBuilder<Wrapper<Holder<B>>>() { }.build(); Type<Decorator<Holder<B>>> toType = new TypeBuilder<Decorator<Holder<B>>>() { }.build(); Decorator<Holder<B>> d = factory.getMapperFacade().map(wrapper, fromType, toType); Assert.assertEquals(wrapper.getHeld(), d.getHeld()); Assert.assertNotSame(wrapper.getHeld(), d.getHeld()); }
From source file:ma.glasnost.orika.test.converter.CloneableConverterTestCase.java
/** * This test method demonstrates that you can decide to treat one of the default cloneable types * as immutable if desired by registering your own PassThroughConverter for that type * // w ww. j av a2s . co m * @throws DatatypeConfigurationException */ @Test public void overrideDefaultCloneableToImmutable() throws DatatypeConfigurationException { PassThroughConverter cc = new PassThroughConverter(Date.class, Calendar.class); MapperFactory factory = MappingUtil.getMapperFactory(); factory.getConverterFactory().registerConverter(cc); GregorianCalendar cal = new GregorianCalendar(); cal.add(Calendar.YEAR, 10); XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance() .newXMLGregorianCalendar((GregorianCalendar) cal); cal.add(Calendar.MONTH, 3); ClonableHolder source = new ClonableHolder(); source.value = new SampleCloneable(); source.value.id = 5L; source.date = new Date(System.currentTimeMillis() + 100000); source.calendar = cal; source.xmlCalendar = xmlCal; ClonableHolder dest = factory.getMapperFacade().map(source, ClonableHolder.class); Assert.assertEquals(source.value, dest.value); Assert.assertNotSame(source.value, dest.value); Assert.assertEquals(source.date, dest.date); Assert.assertSame(source.date, dest.date); Assert.assertEquals(source.calendar, dest.calendar); Assert.assertSame(source.calendar, dest.calendar); Assert.assertEquals(source.xmlCalendar, dest.xmlCalendar); Assert.assertNotSame(source.xmlCalendar, dest.xmlCalendar); }
From source file:com.collective.celos.AbstractStateDatabaseTest.java
@Test public void getAndPutWorksWithExternalIDForPeriod() throws Exception { StateDatabaseConnection db = getStateDatabaseConnection(); WorkflowID workflowID = new WorkflowID("foo"); ScheduledTime startTime = new ScheduledTime("2013-11-27T14:50Z"); ScheduledTime midTime = new ScheduledTime("2013-11-27T15:50Z"); ScheduledTime endTime = new ScheduledTime("2013-11-27T16:50Z"); SlotID slotID1 = new SlotID(workflowID, startTime); SlotID slotID2 = new SlotID(workflowID, midTime); SlotID slotID3 = new SlotID(workflowID, endTime); SlotState state1 = new SlotState(slotID1, SlotState.Status.READY, "externalId1", 1); SlotState state2 = new SlotState(slotID2, SlotState.Status.READY, "externalId2", 2); SlotState state3 = new SlotState(slotID3, SlotState.Status.READY, "externalId3", 3); db.putSlotState(state1);/*from w ww. jav a2 s. c om*/ db.putSlotState(state2); db.putSlotState(state3); Map<SlotID, SlotState> expected = ImmutableMap.of(slotID1, state1, slotID2, state2, slotID3, state3); Map<SlotID, SlotState> anotherExternalId = ImmutableMap.of(slotID1, new SlotState(slotID1, SlotState.Status.READY, "!!!", 1), slotID2, state2, slotID3, state3); Map<SlotID, SlotState> slotStates1 = db.getSlotStates(workflowID, Arrays.asList(startTime, midTime, endTime)); Map<SlotID, SlotState> slotStates2 = db.getSlotStates(workflowID, startTime, endTime.plusSeconds(1)); Assert.assertEquals(expected, slotStates1); Assert.assertEquals(expected, slotStates2); Assert.assertNotSame(anotherExternalId, slotStates2); }
From source file:org.openmrs.module.sync.SyncInvalidRecordTest.java
@Test @NotTransactional// w ww. java 2 s . c o m public void shouldAddInvalidIdentifierTest() throws Exception { runSyncTest(new SyncTestHelper() { @Override public void runOnChild() { } @Override public void changedBeingApplied(List<SyncRecord> syncRecords, Record record) throws Exception { super.changedBeingApplied(syncRecords, record); // Assert that there are no sync records to start with assertNumSyncRecords(0); } @Override public void runOnParent() throws Exception { // Confirm that the identifier failed to save to the DB due to a validation error Patient p = Context.getPatientService().getPatient(2); Collection<PatientIdentifier> identifiers = p.getIdentifiers(); Assert.assertEquals(2, identifiers.size()); for (PatientIdentifier pi : p.getIdentifiers()) { Assert.assertNotSame("54d3ca4a-d1ee-421c-a74e-5336c7519888", pi.getUuid()); } // Since the identifier failed to save, confirm that no sync record was saved either assertNumSyncRecords(0); } }); }
From source file:SdkUnitTests.java
@Test public void EmbeddedSigningTest() { byte[] fileBytes = null; try {//from ww w. j a va2 s . c o m // String currentDir = new java.io.File(".").getCononicalPath(); String currentDir = System.getProperty("user.dir"); Path path = Paths.get(currentDir + SignTest1File); fileBytes = Files.readAllBytes(path); } catch (IOException ioExcp) { Assert.assertEquals(null, ioExcp); } // create an envelope to be signed EnvelopeDefinition envDef = new EnvelopeDefinition(); envDef.setEmailSubject("Please Sign my Java SDK Envelope (Embedded Signer)"); envDef.setEmailBlurb("Hello, Please sign my Java SDK Envelope."); // add a document to the envelope Document doc = new Document(); String base64Doc = Base64.getEncoder().encodeToString(fileBytes); doc.setDocumentBase64(base64Doc); doc.setName("TestFile.pdf"); doc.setDocumentId("1"); List<Document> docs = new ArrayList<Document>(); docs.add(doc); envDef.setDocuments(docs); // Add a recipient to sign the document Signer signer = new Signer(); signer.setEmail(UserName); String name = "Pat Developer"; signer.setName(name); signer.setRecipientId("1"); // this value represents the client's unique identifier for the signer String clientUserId = "2939"; signer.setClientUserId(clientUserId); // Create a SignHere tab somewhere on the document for the signer to sign SignHere signHere = new SignHere(); signHere.setDocumentId("1"); signHere.setPageNumber("1"); signHere.setRecipientId("1"); signHere.setXPosition("100"); signHere.setYPosition("100"); List<SignHere> signHereTabs = new ArrayList<SignHere>(); signHereTabs.add(signHere); Tabs tabs = new Tabs(); tabs.setSignHereTabs(signHereTabs); signer.setTabs(tabs); // Above causes issue envDef.setRecipients(new Recipients()); envDef.getRecipients().setSigners(new ArrayList<Signer>()); envDef.getRecipients().getSigners().add(signer); // send the envelope (otherwise it will be "created" in the Draft folder envDef.setStatus("sent"); try { ApiClient apiClient = new ApiClient(); apiClient.setBasePath(BaseUrl); String creds = createAuthHeaderCreds(UserName, Password, IntegratorKey); apiClient.addDefaultHeader("X-DocuSign-Authentication", creds); Configuration.setDefaultApiClient(apiClient); AuthenticationApi authApi = new AuthenticationApi(); LoginInformation loginInfo = authApi.login(); Assert.assertNotSame(null, loginInfo); Assert.assertNotNull(loginInfo.getLoginAccounts()); Assert.assertTrue(loginInfo.getLoginAccounts().size() > 0); List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts(); Assert.assertNotNull(loginAccounts.get(0).getAccountId()); String accountId = loginInfo.getLoginAccounts().get(0).getAccountId(); EnvelopesApi envelopesApi = new EnvelopesApi(); EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef); Assert.assertNotNull(envelopeSummary); Assert.assertNotNull(envelopeSummary.getEnvelopeId()); System.out.println("EnvelopeSummary: " + envelopeSummary); String returnUrl = "http://www.docusign.com/developer-center"; RecipientViewRequest recipientView = new RecipientViewRequest(); recipientView.setReturnUrl(returnUrl); recipientView.setClientUserId(clientUserId); recipientView.setAuthenticationMethod("email"); recipientView.setUserName(name); recipientView.setEmail(UserName); ViewUrl viewUrl = envelopesApi.createRecipientView(loginInfo.getLoginAccounts().get(0).getAccountId(), envelopeSummary.getEnvelopeId(), recipientView); Assert.assertNotNull(viewUrl); Assert.assertNotNull(viewUrl.getUrl()); // This Url should work in an Iframe or browser to allow signing System.out.println("ViewUrl is " + viewUrl); } catch (ApiException ex) { System.out.println("Exception: " + ex); Assert.assertEquals(null, ex); } }
From source file:com.auditbucket.test.functional.TestMetaHeaderTags.java
@Test public void duplicateDocumentTypes() throws Exception { String mark = "mark@monowai.com"; Authentication authMark = new UsernamePasswordAuthenticationToken(mark, "user1"); SystemUser iSystemUser = regService.registerSystemUser(new RegistrationBean(company, uid, "bah")); Assert.assertNotNull(iSystemUser);// ww w . ja v a 2 s .c o m Fortress fortress = fortressService.registerFortress("duplicateDocumentTypes"); DocumentType dType = tagService.resolveDocType(fortress, "ABC123", true); Assert.assertNotNull(dType); Long id = dType.getId(); dType = tagService.resolveDocType(fortress, "ABC123", false); assertEquals(id, dType.getId()); // Company 2 gets a different tag with the same name SecurityContextHolder.getContext().setAuthentication(authMark); regService.registerSystemUser(new RegistrationBean("secondcompany", mark, "bah")); // Same fortress name, but different company dType = tagService.resolveDocType(fortressService.registerFortress("duplicateDocumentTypes"), "ABC123"); // Creates if missing Assert.assertNotNull(dType); Assert.assertNotSame(id, dType.getId()); }
From source file:SdkUnitTests.java
@Test public void DownLoadEnvelopeDocumentsTest() { byte[] fileBytes = null; try {/*from ww w.j ava2 s.c o m*/ // String currentDir = new java.io.File(".").getCononicalPath(); String currentDir = System.getProperty("user.dir"); Path path = Paths.get(currentDir + SignTest1File); fileBytes = Files.readAllBytes(path); } catch (IOException ioExcp) { Assert.assertEquals(null, ioExcp); } // create an envelope to be signed EnvelopeDefinition envDef = new EnvelopeDefinition(); envDef.setEmailSubject("DownLoadEnvelopeDocumentsTest"); envDef.setEmailBlurb("Hello, Please sign my Java SDK Envelope."); // add a document to the envelope Document doc = new Document(); String base64Doc = Base64.getEncoder().encodeToString(fileBytes); doc.setDocumentBase64(base64Doc); doc.setName("TestFile.pdf"); doc.setDocumentId("1"); List<Document> docs = new ArrayList<Document>(); docs.add(doc); envDef.setDocuments(docs); // Add a recipient to sign the document Signer signer = new Signer(); signer.setEmail(UserName); String name = "Pat Developer"; signer.setName(name); signer.setRecipientId("1"); // this value represents the client's unique identifier for the signer String clientUserId = "2939"; signer.setClientUserId(clientUserId); // Create a SignHere tab somewhere on the document for the signer to sign SignHere signHere = new SignHere(); signHere.setDocumentId("1"); signHere.setPageNumber("1"); signHere.setRecipientId("1"); signHere.setXPosition("100"); signHere.setYPosition("100"); List<SignHere> signHereTabs = new ArrayList<SignHere>(); signHereTabs.add(signHere); Tabs tabs = new Tabs(); tabs.setSignHereTabs(signHereTabs); signer.setTabs(tabs); // Above causes issue envDef.setRecipients(new Recipients()); envDef.getRecipients().setSigners(new ArrayList<Signer>()); envDef.getRecipients().getSigners().add(signer); // send the envelope (otherwise it will be "created" in the Draft folder envDef.setStatus("sent"); try { ApiClient apiClient = new ApiClient(); apiClient.setBasePath(BaseUrl); String creds = createAuthHeaderCreds(UserName, Password, IntegratorKey); apiClient.addDefaultHeader("X-DocuSign-Authentication", creds); Configuration.setDefaultApiClient(apiClient); AuthenticationApi authApi = new AuthenticationApi(); LoginInformation loginInfo = authApi.login(); Assert.assertNotSame(null, loginInfo); Assert.assertNotNull(loginInfo.getLoginAccounts()); Assert.assertTrue(loginInfo.getLoginAccounts().size() > 0); List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts(); Assert.assertNotNull(loginAccounts.get(0).getAccountId()); String accountId = loginInfo.getLoginAccounts().get(0).getAccountId(); EnvelopesApi envelopesApi = new EnvelopesApi(); EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef); Assert.assertNotNull(envelopeSummary); EnvelopeId = envelopeSummary.getEnvelopeId(); Assert.assertNotNull(EnvelopeId); System.out.println("EnvelopeSummary: " + envelopeSummary); byte[] pdfBytes = envelopesApi.getDocument(accountId, EnvelopeId, "combined"); try { File pdfFile = File.createTempFile("ds_", "pdf", null); FileOutputStream fos = new FileOutputStream(pdfFile); fos.write(pdfBytes); // show the PDF Desktop.getDesktop().open(pdfFile); } catch (Exception ex) { Assert.fail("Could not create pdf File"); } } catch (ApiException ex) { System.out.println("Exception: " + ex); Assert.assertEquals(null, ex); } }
From source file:SdkUnitTests.java
@Test public void GetDiagnosticLogsTest() { byte[] fileBytes = null; try {//w ww .j a va2 s. co m // String currentDir = new java.io.File(".").getCononicalPath(); String currentDir = System.getProperty("user.dir"); Path path = Paths.get(currentDir + SignTest1File); fileBytes = Files.readAllBytes(path); } catch (IOException ioExcp) { Assert.assertEquals(null, ioExcp); } // create an envelope to be signed EnvelopeDefinition envDef = new EnvelopeDefinition(); envDef.setEmailSubject("DownLoadEnvelopeDocumentsTest"); envDef.setEmailBlurb("Hello, Please sign my Java SDK Envelope."); // add a document to the envelope Document doc = new Document(); String base64Doc = Base64.getEncoder().encodeToString(fileBytes); doc.setDocumentBase64(base64Doc); doc.setName("TestFile.pdf"); doc.setDocumentId("1"); List<Document> docs = new ArrayList<Document>(); docs.add(doc); envDef.setDocuments(docs); // Add a recipient to sign the document Signer signer = new Signer(); signer.setEmail(UserName); String name = "Pat Developer"; signer.setName(name); signer.setRecipientId("1"); // this value represents the client's unique identifier for the signer String clientUserId = "2939"; signer.setClientUserId(clientUserId); // Create a SignHere tab somewhere on the document for the signer to sign SignHere signHere = new SignHere(); signHere.setDocumentId("1"); signHere.setPageNumber("1"); signHere.setRecipientId("1"); signHere.setXPosition("100"); signHere.setYPosition("100"); List<SignHere> signHereTabs = new ArrayList<SignHere>(); signHereTabs.add(signHere); Tabs tabs = new Tabs(); tabs.setSignHereTabs(signHereTabs); signer.setTabs(tabs); // Above causes issue envDef.setRecipients(new Recipients()); envDef.getRecipients().setSigners(new ArrayList<Signer>()); envDef.getRecipients().getSigners().add(signer); // send the envelope (otherwise it will be "created" in the Draft folder envDef.setStatus("sent"); try { ApiClient apiClient = new ApiClient(); apiClient.setBasePath(BaseUrl); String creds = createAuthHeaderCreds(UserName, Password, IntegratorKey); apiClient.addDefaultHeader("X-DocuSign-Authentication", creds); Configuration.setDefaultApiClient(apiClient); AuthenticationApi authApi = new AuthenticationApi(); LoginInformation loginInfo = authApi.login(); Assert.assertNotSame(null, loginInfo); Assert.assertNotNull(loginInfo.getLoginAccounts()); Assert.assertTrue(loginInfo.getLoginAccounts().size() > 0); List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts(); Assert.assertNotNull(loginAccounts.get(0).getAccountId()); String accountId = loginInfo.getLoginAccounts().get(0).getAccountId(); DiagnosticsApi diagApi = new DiagnosticsApi(); DiagnosticsSettingsInformation diagSettings = new DiagnosticsSettingsInformation(); diagSettings.setApiRequestLogging("true"); diagApi.updateRequestLogSettings(diagSettings); EnvelopesApi envelopesApi = new EnvelopesApi(); EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef); Assert.assertNotNull(envelopeSummary); Assert.assertNotNull(envelopeSummary.getEnvelopeId()); System.out.println("EnvelopeSummary: " + envelopeSummary); byte[] pdfBytes = envelopesApi.getDocument(accountId, envelopeSummary.getEnvelopeId(), "combined"); try { File pdfFile = File.createTempFile("ds_", "pdf", null); FileOutputStream fos = new FileOutputStream(pdfFile); fos.write(pdfBytes); // show the PDF Desktop.getDesktop().open(pdfFile); } catch (Exception ex) { Assert.fail("Could not create pdf File"); } ApiRequestLogsResult logsList = diagApi.listRequestLogs(); String requestLogId = logsList.getApiRequestLogs().get(0).getRequestLogId(); byte[] diagBytes = diagApi.getRequestLog(requestLogId); try { File diagFile = File.createTempFile("ds_", "txt", null); FileOutputStream fos = new FileOutputStream(diagFile); fos.write(diagBytes); // show the PDF Desktop.getDesktop().open(diagFile); } catch (Exception ex) { Assert.fail("Could not create diag log File"); } } catch (ApiException ex) { System.out.println("Exception: " + ex); Assert.assertEquals(null, ex); } }