org.hamcrest.core.IsNull Java Examples

The following examples show how to use org.hamcrest.core.IsNull. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SiteTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSupportRefLink() throws IOException {
    val parentPageTitle = Optional.of("Test");
    val stream = getClass().getClassLoader().getResourceAsStream("withRefLink.md");
    assertThat( stream, IsNull.notNullValue());
    val content = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle);
    assertThat( content, IsNull.notNullValue());
    val converted = content.split("\n+");
    int i = 2;


    assertThat(converted[i++], equalTo(format("* This is a relative link to another page [SECOND PAGE|%s - page 2|].", parentPageTitle.get())) );
    assertThat(converted[i++], equalTo("* This one is [inline|http://google.com|Google].") );
    assertThat(converted[i++], equalTo("* This one is [inline *wo* title|http://google.com|].") );
    assertThat(converted[i++], containsString("[google|http://google.com]"));
    assertThat(converted[i++], containsString("[more complex google|http://google.com|Other google]"));
    assertThat(converted[i++], equalTo("* This is my [relative|relativepage|] link defined after.") );
    assertThat(converted[i++], containsString("[rel|Test - relativeagain]"));
}
 
Example #2
Source File: ExceptionUtilsTest.java    From symbol-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void propagateVoidMapsInterruptedExceptionToIllegalStateException()
    throws InterruptedException {
    // Arrange:
    final InterruptedExceptionTestRunner runner =
        new InterruptedExceptionTestRunner(
            () -> {
                ExceptionUtils.propagateVoid(() -> Thread.sleep(1000));
                return null;
            });

    // Act:
    runner.run();

    // Assert:
    MatcherAssert.assertThat(runner.getUnhandledException(), IsNull.notNullValue());
    MatcherAssert.assertThat(
        runner.getUnhandledException(), IsInstanceOf.instanceOf(IllegalStateException.class));
}
 
Example #3
Source File: ExceptionUtilsTest.java    From symbol-sdk-java with Apache License 2.0 6 votes vote down vote up
@Test
public void propagateMapsInterruptedExceptionToIllegalStateException()
    throws InterruptedException {
    // Arrange:
    final InterruptedExceptionTestRunner runner =
        new InterruptedExceptionTestRunner(
            () ->
                ExceptionUtils.propagate(
                    () -> {
                        Thread.sleep(1000);
                        return null;
                    }));

    // Act:
    runner.run();

    // Assert:
    MatcherAssert.assertThat(runner.getUnhandledException(), IsNull.notNullValue());
    MatcherAssert.assertThat(
        runner.getUnhandledException(), IsInstanceOf.instanceOf(IllegalStateException.class));
}
 
Example #4
Source File: SimpleFileIODatasetPropertiesTest.java    From components with Apache License 2.0 6 votes vote down vote up
/**
 * Check the correct default values in the properties.
 */
@Test
public void testDefaultProperties() {
    assertThat(properties.format.getValue(), is(SimpleFileIOFormat.CSV));
    assertThat(properties.path.getValue(), is(""));
    assertThat(properties.recordDelimiter.getValue(), is(RecordDelimiterType.LF));
    assertThat(properties.specificRecordDelimiter.getValue(), is("\\n"));
    assertThat(properties.fieldDelimiter.getValue(), is(FieldDelimiterType.SEMICOLON));
    assertThat(properties.specificFieldDelimiter.getValue(), is(";"));
    
    assertThat(properties.encoding.getValue(), is(EncodingType.UTF8));
    assertThat(properties.specificEncoding.getValue(), is(""));
    assertThat(properties.setHeaderLine.getValue(), is(false));
    assertThat(properties.headerLine.getValue(), is(1));
    assertThat(properties.textEnclosureCharacter.getValue(), is(""));
    assertThat(properties.escapeCharacter.getValue(), is(""));
    
    assertThat(properties.sheet.getValue(), is(""));
    assertThat(properties.setFooterLine.getValue(), is(false));
    assertThat(properties.footerLine.getValue(), is(IsNull.nullValue()));

    properties.getDatastoreProperties().userName.setValue("ryan");
    String x = JsonSchemaUtil.toJson(properties, Form.MAIN, SimpleFileIODatasetDefinition.NAME);
    System.out.println(x);
}
 
Example #5
Source File: S3DatasetPropertiesTest.java    From components with Apache License 2.0 6 votes vote down vote up
/**
 * Check the correct default values in the properties.
 */
@Test
public void testDefaultProperties() {
    assertThat(properties.format.getValue(), is(SimpleFileIOFormat.CSV));
    assertThat(properties.recordDelimiter.getValue(), is(RecordDelimiterType.LF));
    assertThat(properties.specificRecordDelimiter.getValue(), is("\\n"));
    assertThat(properties.fieldDelimiter.getValue(), is(FieldDelimiterType.SEMICOLON));
    assertThat(properties.specificFieldDelimiter.getValue(), is(";"));
    
    assertThat(properties.encoding.getValue(), is(EncodingType.UTF8));
    assertThat(properties.specificEncoding.getValue(), is(""));
    assertThat(properties.setHeaderLine.getValue(), is(false));
    assertThat(properties.headerLine.getValue(), is(1));
    assertThat(properties.textEnclosureCharacter.getValue(), is(""));
    assertThat(properties.escapeCharacter.getValue(), is(""));
    
    assertThat(properties.sheet.getValue(), is(""));
    assertThat(properties.setFooterLine.getValue(), is(false));
    assertThat(properties.footerLine.getValue(), is(IsNull.nullValue()));

    String x = JsonSchemaUtil.toJson(properties, Form.MAIN, SimpleFileIODatasetDefinition.NAME);
}
 
Example #6
Source File: FeedItemComponentSpecSubComponentTest.java    From litho with Apache License 2.0 6 votes vote down vote up
@Test
public void footerHasNoClickHandler() {
  final ComponentContext c = mComponentsRule.getContext();
  final Component component = makeComponentWithTextInSubcomponent("Any Text");

  // Components commonly have conditional handlers assigned. Using the clickHandler matcher
  // we can assert whether or not a given component has a handler attached to them.
  //noinspection unchecked
  assertThat(c, component)
      .extractingSubComponentAt(0)
      .has(
          subComponentWith(
              c,
              TestFooterComponent.matcher(c)
                  .clickHandler(IsNull.<EventHandler<ClickEvent>>nullValue(null))
                  .build()));
}
 
Example #7
Source File: PermissionsTest.java    From espresso-samples with Apache License 2.0 6 votes vote down vote up
@Before
public void startMainActivityFromHomeScreen() {
    // Initialize UiDevice instance
    device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());

    // Start from the home screen
    device.pressHome();

    // Wait for launcher
    final String launcherPackage = getLauncherPackageName();
    MatcherAssert.assertThat(launcherPackage, IsNull.notNullValue());
    device.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);

    // Launch the app
    Context context = InstrumentationRegistry.getContext();
    final Intent intent = context.getPackageManager()
                                 .getLaunchIntentForPackage(APP_PACKAGE_NAME);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);    // Clear out any previous instances
    context.startActivity(intent);

    // Wait for the app to appear
    device.wait(Until.hasObject(By.pkg(APP_PACKAGE_NAME).depth(0)), LAUNCH_TIMEOUT);
}
 
Example #8
Source File: Issue130IntegrationTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Before
@Override
public void initService() throws Exception {

    setConfluenceUrl("https://localhost:8443/rest/api");
    super.initService();
    
    try {
        // SSL Implementation
        final SSLSocketFactory sslSocketFactory = SSLFactories.newInstance( new YesTrustManager());
        Assert.assertThat(sslSocketFactory, IsNull.notNullValue());
        
        final X509TrustManager trustManager = new YesTrustManager();
        final HostnameVerifier hostnameVerifier = new YesHostnameVerifier();

        restConfluenceService.client
                .hostnameVerifier(hostnameVerifier)
                .sslSocketFactory(sslSocketFactory, trustManager)
                ;
        
    } catch (Exception ex) {
        throw new IllegalStateException(ex);
    }
}
 
Example #9
Source File: SiteTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCreateSpecificNoticeBlock() throws IOException {
   val parentPageTitle = Optional.of("Test Macro");

    val stream = getClass().getClassLoader().getResourceAsStream("createSpecificNoticeBlock.md");
    assertThat( stream, IsNull.notNullValue());
    val converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle);
    assertThat( converted, IsNull.notNullValue());

    assertThat(converted, containsString("{info:title=About me}\n"));
    assertThat("Should not generate unneeded param 'title'", converted, not(containsString("{note:title=}\n")));
    assertThat(converted, containsString("{tip:title=About you}\n"));
    assertThat(converted, containsString("bq. test a simple blockquote"));
    assertThat(converted, containsString("{quote}\n"));
    assertThat(converted, containsString("* one\n* two"));
    assertThat(converted, containsString("a *strong* and _pure_ feeling"));

}
 
Example #10
Source File: SiteTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSupportSimpleNode() throws IOException {
   val parentPageTitle = Optional.of("Test");

    final InputStream stream = getClass().getClassLoader().getResourceAsStream("simpleNodes.md");
    assertThat( stream, IsNull.notNullValue());
    val converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle);
    assertThat( converted, IsNull.notNullValue());

    assertThat("All forms of HRules should be supported", converted, containsString("----\n1\n----\n2\n----\n3\n----\n4\n----"));
    /* only when Extensions.SMARTS is activated
    assertThat(converted, containsString("&hellip;"));
    assertThat(converted, containsString("&ndash;"));
    assertThat(converted, containsString("&mdash;"));
    */
    assertThat(converted, containsString("Forcing a line-break\nNext line in the list"));
    assertThat(converted, containsString("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));
}
 
Example #11
Source File: SiteTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSupportImgRefLink() throws IOException {

    final Model.Page page = TestPage.of( "${page.title}", "spaceKey");

    val parentPageTitle = Optional.of("Test IMG");

    val stream = getClass().getClassLoader().getResourceAsStream("withImgRefLink.md");
    assertThat( stream, IsNull.notNullValue());
    val content = processMarkdown(site, site.getHome(), Optional.of(page), IOUtils.toString(stream), parentPageTitle);
    assertThat( content, IsNull.notNullValue());
   val converted = content.split("\n+");

    int i = 2;
    assertThat(converted[i++], containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|conf-icon!"));
    assertThat(converted[i++], containsString("!${page.title}^conf-icon-64.png|conf-icon!"));
    assertThat(converted[i++], containsString("!${page.title}^conf-icon-64.png|conf-icon!"));
    assertThat(converted[i++], containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|conf-icon-y!"));
    assertThat(converted[i++], containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|conf-icon-y1!"));
    assertThat(converted[i++], containsString("!${page.title}^conf-icon-64.png|conf-icon-y2!"));
    assertThat(converted[i++], containsString("!${page.title}^conf-icon-64.png|conf-icon-none!"));
}
 
Example #12
Source File: SiteTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSupportRefLink() throws IOException {
    val parentPageTitle = Optional.of("Test");
    val stream = getClass().getClassLoader().getResourceAsStream("withRefLink.md");
    assertThat( stream, IsNull.notNullValue());
    val content = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle);
    assertThat( content, IsNull.notNullValue());
    val converted = content.split("\n+");
    int i = 2;


    assertThat(converted[i++], equalTo(format("* This is a relative link to another page [SECOND PAGE|%s - page 2|].", parentPageTitle)) );
    assertThat(converted[i++], equalTo("* This one is [inline|http://google.com|Google].") );
    assertThat(converted[i++], equalTo("* This one is [inline *wo* title|http://google.com|].") );
    assertThat(converted[i++], containsString("[google|http://google.com]"));
    assertThat(converted[i++], containsString("[more complex google|http://google.com|Other google]"));
    assertThat(converted[i++], equalTo("* This is my [relative|relativepage|] link defined after.") );
    assertThat(converted[i++], containsString("[rel|Test - relativeagain]"));
}
 
Example #13
Source File: CheckedBiProcTest.java    From cactoos with MIT License 6 votes vote down vote up
@Test
public void extraWrappingIgnored() {
    try {
        new CheckedBiProc<>(
            (first, second) -> {
                throw new IOException("runtime3");
            },
            IOException::new
        ).exec(true, true);
    } catch (final IOException exp) {
        new Assertion<>(
            "Extra wrapping of IOException has been added",
            exp.getCause(),
            new IsNull<>()
        ).affirm();
    }
}
 
Example #14
Source File: CheckedBiFuncTest.java    From cactoos with MIT License 6 votes vote down vote up
@Test
public void extraWrappingIgnored() {
    try {
        new CheckedBiFunc<>(
            (first, second) -> {
                throw new IOException("runtime3");
            },
            IOException::new
        ).apply(true, true);
    } catch (final IOException exp) {
        new Assertion<>(
            "Extra wrapping of IOException has been added",
            exp.getCause(),
            new IsNull<>()
        ).affirm();
    }
}
 
Example #15
Source File: FailAuthorizationProfileTestCase.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
/**
 * clientIdを作成する.
 * @return clientId
 * @throws Exception clientIdの作成に失敗した場合に発生
 */
private String createClientId() throws Exception {
    String uri = "http://localhost:4035/gotapi/authorization/grant";

    Map<String, String> headers = new HashMap<>();
    headers.put("Origin", getOrigin());

    HttpUtil.Response response = HttpUtil.get(uri, headers);
    assertThat(response, is(notNullValue()));

    JSONObject json = response.getJSONObject();
    assertThat(json, is(notNullValue()));
    assertThat(json.getInt("result"), is(0));
    assertThat(json.getString("clientId"), is(IsNull.notNullValue()));

    return json.getString("clientId");
}
 
Example #16
Source File: ExcelResponseValidationSteps.java    From vividus with Apache License 2.0 6 votes vote down vote up
private void reportResults(Stream<String> ranges, List<Entry<CellValue, Optional<Pattern>>> failedRecords)
{
    if (failedRecords.isEmpty())
    {
        softAssert.recordPassedAssertion(format("All records at ranges %s are matched in the document",
                ranges.collect(Collectors.joining(", "))));
        return;
    }
    failedRecords.forEach(e ->
    {
        CellValue cellValue = e.getKey();
        Matcher<String> matcher = e.getValue().map(Matchers::matchesPattern).orElseGet(IsNull<String>::new);
        softAssert.assertThat(format("Cell at address '%s'", cellValue.getAddress()), cellValue.getValue(),
                matcher);
    });
}
 
Example #17
Source File: SiteTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSupportImgRefLink() throws IOException {

    final Model.Page page = TestPage.of( "${page.title}", "spaceKey");

    final val parentPageTitle = Optional.of("Test IMG");

    final InputStream stream = getClass().getClassLoader().getResourceAsStream("withImgRefLink.md");
    assertThat( stream, IsNull.notNullValue());
    val content = processMarkdown(site, site.getHome(), Optional.of(page), IOUtils.toString(stream), parentPageTitle);
    assertThat( content, IsNull.notNullValue());
    final String converted[] = content.split("\n+");

    int i = 2;
    assertThat(converted[i++], containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|conf-icon!"));
    assertThat(converted[i++], containsString("!${page.title}^conf-icon-64.png|conf-icon!"));
    assertThat(converted[i++], containsString("!${page.title}^conf-icon-64.png|conf-icon!"));
    assertThat(converted[i++], containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|conf-icon-y!"));
    assertThat(converted[i++], containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|conf-icon-y1!"));
    assertThat(converted[i++], containsString("!${page.title}^conf-icon-64.png|conf-icon-y2!"));
    assertThat(converted[i++], containsString("!${page.title}^conf-icon-64.png|conf-icon-none!"));
}
 
Example #18
Source File: SiteTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSupportSimpleNode() throws IOException {
    val parentPageTitle = Optional.of("Test");

    final InputStream stream = getClass().getClassLoader().getResourceAsStream("simpleNodes.md");
    assertThat( stream, IsNull.notNullValue());
    val converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle);
    assertThat( converted, IsNull.notNullValue());

    assertThat("All forms of HRules should be supported", converted, containsString("----\n1\n----\n2\n----\n3\n----\n4\n----"));
    /* only when Extensions.SMARTS is activated
    assertThat(converted, containsString("&hellip;"));
    assertThat(converted, containsString("&ndash;"));
    assertThat(converted, containsString("&mdash;"));
    */
    assertThat(converted, containsString("Forcing a line-break\nNext line in the list"));
    assertThat(converted, containsString("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));
}
 
Example #19
Source File: SiteTest.java    From maven-confluence-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldCreateSpecificNoticeBlock() throws IOException {
    val parentPageTitle = Optional.of("Test Macro");

    final InputStream stream = getClass().getClassLoader().getResourceAsStream("createSpecificNoticeBlock.md");
    assertThat( stream, IsNull.notNullValue());
    val converted = processMarkdown(site, site.getHome(), Optional.empty(), IOUtils.toString(stream), parentPageTitle);
    assertThat( converted, IsNull.notNullValue());

    assertThat(converted, containsString("{info:title=About me}\n"));
    assertThat("Should not generate unneeded param 'title'", converted, not(containsString("{note:title=}\n")));
    assertThat(converted, containsString("{tip:title=About you}\n"));
    assertThat(converted, containsString("bq. test a simple blockquote"));
    assertThat(converted, containsString("{quote}\n"));
    assertThat(converted, containsString("* one\n* two"));
    assertThat(converted, containsString("a *strong* and _pure_ feeling"));

}
 
Example #20
Source File: PaymentServiceTest.java    From servicecomb-pack with Apache License 2.0 6 votes vote down vote up
@Test
public void testPaymentServicePaymentJustAsCredit() {
  payment.setId(1);
  payment.setUserName("UserB");
  payment.setAmount(10);
  paymentService.pay(payment);
  assertThat(payment.getBalance(), IsNull.nullValue());
  assertThat(paymentService.getAccount(payment).getCredit(), is(0));
  assertThat(paymentService.getAccount(payment).getBalance(), is(10));
  assertThat(paymentService.getAllTransactions().size(), is(1));

  paymentService.confirm(payment);
  assertThat(payment.isCancelled(), is(false));
  assertThat(payment.isConfirmed(), is(true));
  assertThat(paymentService.getAccount(payment).getCredit(), is(0));
  assertThat(paymentService.getAccount(payment).getBalance(), is(0));
  assertThat(payment.getBalance(), is(0));
}
 
Example #21
Source File: CheckedBytesTest.java    From cactoos with MIT License 6 votes vote down vote up
@Test
public void extraWrappingIgnored() {
    try {
        new CheckedBytes<>(
            () -> {
                throw new IOException("runtime3");
            },
            IOException::new
        ).asBytes();
    } catch (final IOException exp) {
        new Assertion<>(
            "must not add extra wrapping of IOException",
            exp.getCause(),
            new IsNull<>()
        ).affirm();
    }
}
 
Example #22
Source File: CheckedOutputTest.java    From cactoos with MIT License 6 votes vote down vote up
@Test
public void extraWrappingIgnored() {
    try {
        new CheckedOutput<>(
            () -> {
                throw new IOException("runtime3");
            },
            IOException::new
        ).stream();
    } catch (final IOException exp) {
        new Assertion<>(
            "must not add extra wrapping of IOException",
            exp.getCause(),
            new IsNull<>()
        ).affirm();
    }
}
 
Example #23
Source File: CheckedInputTest.java    From cactoos with MIT License 6 votes vote down vote up
@Test
public void extraWrappingIgnored() {
    try {
        new CheckedInput<>(
            () -> {
                throw new IOException("runtime3");
            },
            IOException::new
        ).stream();
    } catch (final IOException exp) {
        new Assertion<>(
            "must not add extra wrapping of IOException",
            exp.getCause(),
            new IsNull<>()
        ).affirm();
    }
}
 
Example #24
Source File: CheckedProcTest.java    From cactoos with MIT License 6 votes vote down vote up
@Test
public void extraWrappingIgnored() {
    try {
        new CheckedProc<>(
            input -> {
                throw new IOException("runtime3");
            },
            IOException::new
        ).exec(true);
    } catch (final IOException exp) {
        new Assertion<>(
            "Extra wrapping of IOException has been added",
            exp.getCause(),
            new IsNull<>()
        ).affirm();
    }
}
 
Example #25
Source File: CheckedFuncTest.java    From cactoos with MIT License 6 votes vote down vote up
@Test
public void extraWrappingIgnored() {
    try {
        new CheckedFunc<>(
            input -> {
                throw new IOException("runtime3");
            },
            IOException::new
        ).apply(true);
    } catch (final IOException exp) {
        new Assertion<>(
            "Extra wrapping of IOException has been added",
            exp.getCause(),
            new IsNull<>()
        ).affirm();
    }
}
 
Example #26
Source File: HttpVoidResponseStrategyTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void getSupportedContentTypeReturnsCorrectContentType() throws Exception {
	// Arrange:
	final HttpVoidResponseStrategy strategy = new HttpVoidResponseStrategy();

	// Assert:
	Assert.assertThat(strategy.getSupportedContentType(), IsNull.nullValue());
}
 
Example #27
Source File: TransactionMetaDataTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void canRoundTripTransactionMetaData() {
	// Arrange:
	final Hash hash = Utils.generateRandomHash();
	final TransactionMetaData metaData = createRoundTrippedMetaData(7546, 456, hash);

	// Assert:
	Assert.assertThat(metaData.getHeight(), IsEqual.equalTo(new BlockHeight(7546)));
	Assert.assertThat(metaData.getId(), IsEqual.equalTo(456L));
	Assert.assertThat(metaData.getHash(), IsEqual.equalTo(hash));
	Assert.assertThat(metaData.getInnerHash(), IsNull.nullValue());
}
 
Example #28
Source File: HttpVoidResponseStrategyTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void nullIsReturnedIfRequestSucceedsAndNoDataIsReturned() throws Exception {
	// Arrange:
	final HttpVoidResponseStrategy strategy = new HttpVoidResponseStrategy();

	// Act:
	final Deserializer deserializer = ConnectUtils.coerceDeserializer(new byte[] {}, strategy);

	// Assert:
	Assert.assertThat(deserializer, IsNull.nullValue());
}
 
Example #29
Source File: Ed25519BlockCipherTest.java    From nem.core with MIT License 5 votes vote down vote up
@Test
public void decryptReturnsNullIfInputIsTooSmallInLength() {
	// Arrange:
	final CryptoEngine engine = this.getCryptoEngine();
	final KeyPair kp = KeyPair.random(engine);
	final BlockCipher blockCipher = this.getBlockCipher(kp, kp);

	// Act:
	final byte[] decryptedBytes = blockCipher.decrypt(new byte[63]);

	// Assert:
	Assert.assertThat(decryptedBytes, IsNull.nullValue());
}
 
Example #30
Source File: RemoteHamcrestCoreMatcher13Test.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Test
public void isNull_transformationFromProto() {
  IsNull isNullMatcher = new IsNull();
  GenericRemoteMessage isNullMatcherRemoteMsg = new GenericRemoteMessage(isNullMatcher);
  IsNullProto isNullMatcherProto = (IsNullProto) isNullMatcherRemoteMsg.toProto();
  IsNull isNullMatcherFromProto =
      (IsNull) GenericRemoteMessage.FROM.fromProto(isNullMatcherProto);

  assertThat(null, isNullMatcherFromProto);
}