Java Code Examples for org.fest.assertions.api.Assertions#fail()

The following examples show how to use org.fest.assertions.api.Assertions#fail() . 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: ParcelTests.java    From android-sdk with MIT License 6 votes vote down vote up
@Test
public void test_action_parcelable() {
    UriMessageAction action = new UriMessageAction(UUID.randomUUID(), "title", "content", "foo.bar", null, 0, UUID.randomUUID().toString());

    try {
        Parcel parcel = Parcel.obtain();
        Bundle bundle = new Bundle();
        bundle.putParcelable("some_value", action);
        bundle.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);

        Bundle reverse = Bundle.CREATOR.createFromParcel(parcel);
        reverse.setClassLoader(BeaconId.class.getClassLoader());
        UriMessageAction action2 = reverse.getParcelable("some_value");

        Assertions.assertThat(action.getTitle()).isEqualTo(action2.getTitle());
        Assertions.assertThat(action.getContent()).isEqualTo(action2.getContent());
        Assertions.assertThat(action.getUri()).isEqualTo(action2.getUri());
        Assertions.assertThat(action.getType()).isEqualTo(action2.getType());

        Assertions.assertThat(action2).isEqualTo(action);
    } catch (Exception e) {
        Assertions.fail("could not parcel the BeaconEvent " + e.getMessage());
    }
}
 
Example 2
Source File: ParcelTests.java    From android-sdk with MIT License 6 votes vote down vote up
@Test
public void testBeaconEvent() {
    Action action = new UriMessageAction(UUID.randomUUID(), "title", "content", "foo.bar", null, 0, UUID.randomUUID().toString());
    BeaconEvent event = new BeaconEvent.Builder()
            .withAction(action)
            .build();

    try {
        Parcel parcel = Parcel.obtain();
        event.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);

        BeaconEvent beaconEvent2 = BeaconEvent.CREATOR.createFromParcel(parcel);

        Assertions.assertThat(beaconEvent2.getAction()).isEqualTo(event.getAction());
        Assertions.assertThat(beaconEvent2.getAction()).isEqualTo(event.getAction());

        Assertions.assertThat(beaconEvent2).isEqualTo(event);
    } catch (Exception e) {
        Assertions.fail("could not parcel the BeaconEvent " + e.getMessage());
    }
}
 
Example 3
Source File: ParcelTests.java    From android-sdk with MIT License 6 votes vote down vote up
@Test
public void testBeaconEvent_withBundle() {
    Action action = new UriMessageAction(UUID.randomUUID(), "title", "content", "foo.bar", null, 0, UUID.randomUUID().toString());
    BeaconEvent event = new BeaconEvent.Builder()
            .withAction(action)
            .build();

    try {
        Parcel parcel = Parcel.obtain();
        Bundle bundle = new Bundle();
        bundle.putParcelable("some_value", event);
        bundle.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);

        Bundle reverse = Bundle.CREATOR.createFromParcel(parcel);
        reverse.setClassLoader(BeaconId.class.getClassLoader());
        BeaconEvent beaconEvent2 = reverse.getParcelable("some_value");

        Assertions.assertThat(beaconEvent2.getAction()).isEqualTo(event.getAction());
        Assertions.assertThat(beaconEvent2.getAction()).isEqualTo(event.getAction());

        Assertions.assertThat(beaconEvent2).isEqualTo(event);
    } catch (Exception e) {
        Assertions.fail("could not parcel the BeaconEvent " + e.getMessage());
    }
}
 
Example 4
Source File: SmtpAssertions.java    From batchers with Apache License 2.0 5 votes vote down vote up
public SmtpAssertions hasReceivedMessageContaining(String text) {
    List<WiserMessage> messages = actual.getMessages();
    for (WiserMessage message : messages) {
        if (new String(message.getData()).contains(text)) {
            return this;
        }
    }
    Assertions.fail("Could not find a message containt text '" + text + "'");
    return this;
}
 
Example 5
Source File: SmtpAssertions.java    From batchers with Apache License 2.0 5 votes vote down vote up
public SmtpAssertions hasReceivedMessageSentTo(String receiver) {
    List<WiserMessage> messages = actual.getMessages();
    for (WiserMessage message : messages) {
        if (message.getEnvelopeReceiver().equals(receiver)) {
            return this;
        }
    }
    Assertions.fail("Could not find a message containt sent to '" + receiver + "'");
    return this;
}
 
Example 6
Source File: SmtpAssertions.java    From batchers with Apache License 2.0 5 votes vote down vote up
public SmtpAssertions hasReceivedMessageSentFrom(String sender) {
    List<WiserMessage> messages = actual.getMessages();
    for (WiserMessage message : messages) {
        if (message.getEnvelopeSender().equals(sender)) {
            return this;
        }
    }
    Assertions.fail("Could not find a message containt sent to '" + sender + "'");
    return this;
}
 
Example 7
Source File: TheInternalBootstrapperIntegration.java    From android-sdk with MIT License 5 votes vote down vote up
@Test
    public void test_precaching() {
        try {
            ResolveResponse updateLayoutResponse = gson
                    .fromJson(Utils.getRawResourceAsString(com.sensorberg.sdk.test.R.raw.response_resolve_precaching,
                            InstrumentationRegistry.getContext()), ResolveResponse.class);
            Mockito.when(mockRetrofitApiService.updateBeaconLayout(Matchers.<TreeMap<String, String>>any())).thenReturn(Calls.response(updateLayoutResponse));

            ResolveResponse getBeaconResponse = gson.fromJson(Utils.getRawResourceAsString(com.sensorberg.sdk.test.R.raw.response_resolve_precaching,
                    InstrumentationRegistry.getContext()), ResolveResponse.class);
            Mockito.when(mockRetrofitApiService.getBeacon(Mockito.anyString(), Mockito.anyString(), Matchers.<TreeMap<String, String>>any()))
                    .thenReturn(Calls.response(getBeaconResponse));
        } catch (Exception e) {
            Assertions.fail(e.toString());
        }

        System.out.println("TheInternalBootstrapperIntegration start test_precaching");
        spiedInternalApplicationBootstrapper.updateBeaconLayout();

        //simulate the entry
        spiedInternalApplicationBootstrapper.onScanEventDetected(TestConstants.BEACON_SCAN_ENTRY_EVENT(0));

        Mockito.verify(spiedTransportWithMockService, Mockito.timeout(5000).times(1))
                .getBeacon(Mockito.any(ScanEvent.class), Matchers.<TreeMap<String, String>>any(), Mockito.any(BeaconResponseHandler.class));
        Mockito.verify(spiedTransportWithMockService, Mockito.timeout(5000).times(1))
                .updateBeaconLayout(Matchers.<TreeMap<String, String>>any());

        //TODO this does get called in real code and during debugging, but Mockito says it doesn't
//        Mockito.verify(spiedInternalApplicationBootstrapper, Mockito.timeout(5000).times(1))
//                .presentBeaconEvent(Mockito.any(BeaconEvent.class));
    }
 
Example 8
Source File: ParcelTests.java    From android-sdk with MIT License 5 votes vote down vote up
@Test
public void test_ScanEvent() {
    ScanEvent scanEvent = new ScanEvent.Builder()
            .withEventTime(10)
            .withBeaconId(new BeaconId(UUID.randomUUID(), 1, 1))
            .withEventTime(12)
            .build();

    try {
        Parcel parcel = Parcel.obtain();
        Bundle bundle = new Bundle();
        bundle.putParcelable("some_value", scanEvent);
        bundle.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);

        Bundle reverse = Bundle.CREATOR.createFromParcel(parcel);
        reverse.setClassLoader(BeaconId.class.getClassLoader());
        ScanEvent scanEvent2 = reverse.getParcelable("some_value");

        Assertions.assertThat(scanEvent.getBeaconId()).isEqualTo(scanEvent2.getBeaconId());
        Assertions.assertThat(scanEvent.isEntry()).isEqualTo(scanEvent2.isEntry());
        Assertions.assertThat(scanEvent.getEventTime()).isEqualTo(scanEvent2.getEventTime());

        Assertions.assertThat(scanEvent2).isEqualTo(scanEvent);
    } catch (Exception e) {
        Assertions.fail("could not parcel the BeaconEvent " + e.getMessage());
    }

}
 
Example 9
Source File: TheBeaconMapShould.java    From android-sdk with MIT License 5 votes vote down vote up
@Test
public void not_fail_if_file_does_not_exist() throws IOException {
    File tempFile = getTempFile();
    tempFile.delete();
    try {
        tested = new BeaconMap(testFileManager, tempFile);
    } catch (Exception e) {
        Assertions.fail(e.getMessage());
    }
}