@Test public void testSpannableWithClickableSpans() { Spannable clickableText = Spannable.Factory.getInstance().newSpannable("Some text."); clickableText.setSpan(new ClickableSpan() { @Override public void onClick(View widget) { } }, 0, 1, 0); TextDrawable drawable = getMountedDrawableForText(clickableText); assertThat(drawable.getClickableSpans()).isNotNull().hasSize(1); }
@Test public void testSpannableWithoutClickableSpans() { Spannable nonClickableText = Spannable.Factory.getInstance().newSpannable("Some text."); TextDrawable drawable = getMountedDrawableForText(nonClickableText); assertThat(drawable.getClickableSpans()).isNotNull().hasSize(0); }
@Test public void testNullInStringArray() { PersistableBundleCompat bundle = new PersistableBundleCompat(); String[] array = {"111", null, "333"}; bundle.putStringArray("array", array); bundle = PersistableBundleCompat.fromXml(bundle.saveToXml()); String[] inflated = bundle.getStringArray("array"); assertThat(inflated).isNotNull().hasSize(3).containsExactly("111", null, "333"); } }
@Test public void injectUnitVariablesNoDataSourceInUnit() { factory.bindVariable("numberVariable", BigDecimal.ONE); factory.bindVariable("stringList", Collections.singletonList("test")); final TestRuleUnit testRuleUnit = new TestRuleUnit(new Integer[]{}, BigDecimal.ZERO); testRuleUnit.getStringList().add("bla"); final InternalRuleUnitExecutor ruleUnitExecutor = mock(InternalRuleUnitExecutor.class); factory.injectUnitVariables(ruleUnitExecutor, testRuleUnit); // Unassigned variables or numbers equal 0 should be reassigned if a variable exists. assertThat(testRuleUnit.getNumber()).isEqualTo(BigDecimal.ONE); // Others should remain the same. assertThat(testRuleUnit.bound).isFalse(); assertThat(testRuleUnit.getNumbersArray()).isNotNull().isEmpty(); assertThat(testRuleUnit.getSimpleFactList()).isNotNull().isEmpty(); assertThat(testRuleUnit.getStringList()).isNotNull().hasSize(1).containsExactly("bla"); verifyZeroInteractions(ruleUnitExecutor); }
/** * Assert that the message has recipients of a specific type. * * @param type the type of recipients to check for. * @return the assertion for chaining. */ public MailMessagesAssertions hasRecipients(RecipientType type) { checkNotNull(); try { assertThat(actual.getRecipients(type)).isNotNull(); assertThat(actual.getRecipients(type)).isNotEmpty(); } catch (MessagingException e) { throwException(e, NO_RECIPIENTS_SPECIFIED); } return this; }
private ProcessInstanceAssert isWaitingFor(final String[] messageNames, boolean isWaitingFor) { isNotNull(); Assertions.assertThat(messageNames) .overridingErrorMessage("Expecting list of messageNames not to be null, not to be empty and not to contain null values: %s." , Lists.newArrayList(messageNames)) .isNotNull().isNotEmpty().doesNotContainNull(); for (String messageName : messageNames) { List<Execution> executions = executionQuery().messageEventSubscriptionName(messageName).list(); ListAssert<Execution> assertion = Assertions.assertThat(executions).overridingErrorMessage("Expecting %s " + (isWaitingFor ? "to be waiting for %s, " : "NOT to be waiting for %s, ") + "but actually did " + (isWaitingFor ? "not " : "") + "find it to be waiting for message [%s].", actual, Arrays.asList(messageNames), messageName); if (isWaitingFor) { assertion.isNotEmpty(); } else { assertion.isEmpty(); } } return this; }
private ProcessInstanceAssert isWaitingFor(final String[] messageNames, boolean isWaitingFor) { isNotNull(); Assertions.assertThat(messageNames) .overridingErrorMessage("Expecting list of messageNames not to be null, not to be empty and not to contain null values: %s." , Lists.newArrayList(messageNames)) .isNotNull().isNotEmpty().doesNotContainNull(); for (String messageName: messageNames) { List<Execution> executions = executionQuery().messageEventSubscriptionName(messageName).list(); ListAssert<Execution> assertion = (ListAssert<Execution>) Assertions.assertThat(executions).overridingErrorMessage("Expecting %s " + (isWaitingFor ? "to be waiting for %s, ": "NOT to be waiting for %s, ") + "but actually did " + (isWaitingFor ? "not ": "") + "find it to be waiting for message [%s].", actual, Arrays.asList(messageNames), messageName); if (isWaitingFor) { assertion.isNotEmpty(); } else { assertion.isEmpty(); } } return this; }
@Test public void testInstalledHook() { final URI newRepo = URI.create("git://hook-repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); if (fs instanceof JGitFileSystemImpl) { File[] hooks = new File(((JGitFileSystemImpl) fs).getGit().getRepository().getDirectory(), "hooks").listFiles(); assertThat(hooks).isNotEmpty().isNotNull(); assertThat(hooks.length).isEqualTo(2); boolean foundPreCommitHook = false; boolean foundPostCommitHook = false; for (File hook : hooks) { if (hook.getName().equals("pre-commit")) { foundPreCommitHook = hook.canExecute(); } else if (hook.getName().equals("post-commit")) { foundPostCommitHook = hook.canExecute(); } } assertThat(foundPreCommitHook).isTrue(); assertThat(foundPostCommitHook).isTrue(); } }
@Test public void createTrustManagers() throws Exception { final TrustManager[] trustManagers = ActiveMQUtil.createTrustManagers(TEST_CERT); assertThat(trustManagers).isNotNull().isNotEmpty(); } }
@Test public void testInstalledHook() { final URI newRepo = URI.create("git://hook-repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); if (fs instanceof JGitFileSystemImpl) { File[] hooks = new File(((JGitFileSystemImpl) fs).getGit().getRepository().getDirectory(), "hooks").listFiles(); assertThat(hooks).isNotEmpty().isNotNull(); assertThat(hooks.length).isEqualTo(2); boolean foundPreCommitHook = false; boolean foundPostCommitHook = false; for (File hook : hooks) { if (hook.getName().equals("pre-commit")) { foundPreCommitHook = hook.canExecute(); } else if (hook.getName().equals("post-commit")) { foundPostCommitHook = hook.canExecute(); } } assertThat(foundPreCommitHook).isTrue(); assertThat(foundPostCommitHook).isTrue(); } }
@Test public void serializesOnlyNonEmptyCustomArray() throws Exception { JsonAdapter<Data1> adapter = moshi.adapter(Data1.class); Data1 fromJson = adapter.fromJson("{\n" + "\"customArray\": [{" + "\"data\":\"blub\"" + "}]\n" + "}"); assertThat(fromJson.customArray).isNotNull().hasSize(1); assertThat(fromJson.customArray[0].data).isEqualTo("blub"); fromJson.customArray = new CustomType[0]; assertThat(adapter.toJson(fromJson)).isEqualTo("{}"); fromJson.customArray = new CustomType[] { new CustomType("blub") }; assertThat(adapter.toJson(fromJson)).isEqualTo("{\"customArray\":[{\"data\":\"blub\"}]}"); }
@Test public void testGetStringAttributesExistsEmpty() throws Exception { final Attributes attrs = new BasicAttributes(); Attribute multi = new BasicAttribute("abc"); attrs.put(multi); class TestableDirContextAdapter extends DirContextAdapter { public TestableDirContextAdapter() { super(attrs, null); } } tested = new TestableDirContextAdapter(); String s[] = tested.getStringAttributes("abc"); assertThat(s).isNotNull(); assertThat(s.length).isEqualTo(0); }
@Test public void createKeyManagers() throws Exception { /* StringBuffer sb = new StringBuffer(); Provider[] p = Security.getProviders(); for (int i = 0; i < p.length; i++) { sb.append("\nProvider : " + p[i].toString() + "\n"); Set s = p[i].keySet(); Object[] o = s.toArray(); Arrays.sort(o); for (int j = 1; j < o.length; j++) { sb.append(o[j].toString() + ", "); } } System.out.println(sb.toString()); */ final KeyManager[] keyManagers = ActiveMQUtil.createKeyManagers(TEST_CERT); assertThat(keyManagers).isNotNull().isNotEmpty(); }
@Test public void getRandomInstance_should_return_requested_instance_if_available() { // given: all available SecureRandom algorithm providers Provider[] availableProviders = Security.getProviders(); assertThat(availableProviders).isNotNull(); assertThat(availableProviders.length).isGreaterThanOrEqualTo(1); // Ignore some algorithms because they fail on OSX if you're not an admin. // We don't care that *all* algorithms are available at all times on all platforms, just that the code does what it's supposed to do. List<String> excludedAlgorithms = Collections.singletonList("NativePRNGNonBlocking"); Set<String> availableSecureRandomAlgorithms = new HashSet<>(); for (Provider provider : availableProviders) { Set<Provider.Service> services = provider.getServices(); for (Provider.Service service : services) { String type = service.getType(); if ("SecureRandom".equals(type) && !excludedAlgorithms.contains(service.getAlgorithm())) availableSecureRandomAlgorithms.add(service.getAlgorithm()); } } assertThat(availableSecureRandomAlgorithms).isNotEmpty(); for (String algorithm : availableSecureRandomAlgorithms) { // when: we ask getRandomInstance for the algorithm Random randomGenerator = TraceAndSpanIdGenerator.getRandomInstance(algorithm); // then: we get back a valid SecureRandom that uses the requested algorithm assertThat(randomGenerator).isNotNull(); assertThat(randomGenerator).isInstanceOf(SecureRandom.class); //noinspection ConstantConditions assertThat(((SecureRandom)randomGenerator).getAlgorithm()).isEqualTo(algorithm); } }
.overridingErrorMessage("Expecting list of activityIds not to be null, not to be empty and not to contain null values: %s." , Lists.newArrayList(activityIds)) .isNotNull().isNotEmpty().doesNotContainNull(); final List<String> activeActivityIds = runtimeService().getActiveActivityIds(actual.getId()); final String message = "Expecting %s " +
.overridingErrorMessage("Expecting list of activityIds not to be null, not to be empty and not to contain null values: %s." , Lists.newArrayList(activityIds)) .isNotNull().isNotEmpty().doesNotContainNull(); final List<String> activeActivityIds = runtimeService().getActiveActivityIds(actual.getId()); final String message = "Expecting %s " +
boolean foundPostCommitHook = false; File[] hooks = new File(cloned.getRepository().getDirectory(), "hooks").listFiles(); assertThat(hooks).isNotEmpty().isNotNull(); assertThat(hooks.length).isEqualTo(2); for (File hook : hooks) {
@Test public void nowPlaying() throws Exception { // //Arrange // Map<String, Integer> mapToSend = new HashMap<>(); mapToSend.put("page", 1); // //Act // TestObserver<ServiceResponse> testObserver = serviceApi.nowPlaying(API_TOKEN, mapToSend).test(); testScheduler.triggerActions(); // //Assert // testObserver.assertComplete(); testObserver.assertNoErrors(); testObserver.assertValueCount(1); ServiceResponse serviceResponse = (ServiceResponse) testObserver.getEvents().get(0).get(0); assertThat(serviceResponse.getPage()).isEqualTo(1); assertThat(serviceResponse.getResults()).isNotNull(); assertThat(serviceResponse.getDates()).isNotNull(); assertThat(serviceResponse.getTotal_pages()).isGreaterThan(0); assertThat(serviceResponse.getTotal_results()).isGreaterThan(0); } }
boolean foundPostCommitHook = false; File[] hooks = new File(cloned.getRepository().getDirectory(), "hooks").listFiles(); assertThat(hooks).isNotEmpty().isNotNull(); assertThat(hooks.length).isEqualTo(2); for (File hook : hooks) {
boolean foundPostCommitHook = false; File[] hooks = new File(cloned.getRepository().getDirectory(), "hooks").listFiles(); assertThat(hooks).isNotEmpty().isNotNull(); assertThat(hooks.length).isEqualTo(2); for (File hook : hooks) {