/** * Creates a new instance of <code>{@link ThrowableAssert}</code>. * @param actual the actual value. * @return the created assertion Throwable. */ public static ThrowableAssert assertThat(Throwable actual) { return new ThrowableAssert(actual); }
.isInstanceOf(IndexOutOfBoundsException.class) // .hasMessage("Index: 1, Size: 0") // .hasNoCause(); then(null).isInstanceOf(IndexOutOfBoundsException.class); then(new RuntimeException()).isInstanceOf( IndexOutOfBoundsException.class); .isInstanceOf(IndexOutOfBoundsException.class) // .hasMessageStartingWith("Index: 1") // .hasMessageEndingWith("Size: 0") // .hasMessageContaining("Size") // .hasMessage("Hi!");
@Test public void debugTest() { Timber.plant(new Timber.DebugTree()); logger.debug("Hello, world!"); List<LogItem> logs = ShadowLog.getLogs(); assertThat(logs).hasSize(1); LogItem log = logs.get(0); assertThat(log.type).isEqualTo(Log.DEBUG); assertThat(log.tag).isEqualTo("TimberLoggerAdapterTest"); assertThat(log.msg).isEqualTo("Hello, world!"); assertThat(log.throwable).isNull(); } }
@Test public void puttingNullValueThrowsException() { try { from("hi {name}").put("name", null); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { assertThat(e).hasMessage("Null value for 'name'"); } }
PROVIDER.move( source, target ); } catch ( org.kie.commons.java.nio.IOException e ) { assertThat( e.getCause() ).isInstanceOf( DirectoryNotEmptyException.class );
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @Test public void givenOpeningSessionError_whenAcquiringSession_thenReturnsInvalidDrmSession() throws MediaDrmException { ResourceBusyException resourceBusyException = new ResourceBusyException("resource is busy"); given(mediaDrm.openSession()).willThrow(resourceBusyException); DrmSession<FrameworkMediaCrypto> drmSession = localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA); assertThat(drmSession).isInstanceOf(InvalidDrmSession.class); assertThat(drmSession.getError().getCause()).isEqualTo(resourceBusyException); }
.isInstanceOf(IndexOutOfBoundsException.class) // .hasMessage("Index: 1, Size: 0") // .hasNoCause(); then(null).isInstanceOf(IndexOutOfBoundsException.class); then(new RuntimeException()).isInstanceOf(IndexOutOfBoundsException.class); .isInstanceOf(IndexOutOfBoundsException.class) // .hasMessageStartingWith("Index: 1") // .hasMessageEndingWith("Size: 0") // .hasMessageContaining("Size") // .hasMessage("Hi!");
@Test public void testEmptyConstraints() throws Exception { DataSetLookupConstraints constraints = new DataSetLookupConstraints() .setColumnTypes(null) .setGroupRequired(false); DataSetLookup lookup = constraints.newDataSetLookup(dataSet.getMetadata()); assertThat(constraints.check(lookup)).isNull(); DataSet result = dataSetManager.lookupDataSet(lookup); assertThat(result.getColumns().size()).isEqualTo(6); assertThat(result.getRowCount()).isEqualTo(50); }
@Test public void testGroupMultipleColumns() throws Exception { DataSetLookupConstraints constraints = new DataSetLookupConstraints() .setColumnTypes(new ColumnType[] {LABEL, NUMBER, NUMBER, NUMBER}) .setGroupRequired(true); DataSetLookup lookup = constraints.newDataSetLookup(dataSet.getMetadata()); assertThat(constraints.check(lookup)).isNull(); DataSet result = dataSetManager.lookupDataSet(lookup); assertDataSetValues(result, dataSetFormatter, new String[][] { {"Barcelona", "21.00", "2,913.14", "21.00"}, {"Madrid", "57.00", "2,453.36", "57.00"}, {"Brno", "153.00", "4,659.24", "153.00"}, {"Westford", "234.00", "3,594.97", "234.00"}, {"Raleigh", "481.00", "4,970.78", "481.00"}, {"London", "329.00", "4,139.77", "329.00"} }, 0); }
@Test public void testGroupWithOneCalculation() throws Exception { DataSetLookupConstraints constraints = new DataSetLookupConstraints() .setColumnTypes(new ColumnType[] {LABEL, NUMBER}) .setGroupRequired(true); DataSetLookup lookup = constraints.newDataSetLookup(dataSet.getMetadata()); assertThat(constraints.check(lookup)).isNull(); DataSet result = dataSetManager.lookupDataSet(lookup); assertDataSetValues(result, dataSetFormatter, new String[][] { {"Barcelona", "21.00"}, {"Madrid", "57.00"}, {"Brno", "153.00"}, {"Westford", "234.00"}, {"Raleigh", "481.00"}, {"London", "329.00"} }, 0); }
@Test public void testGroupWithLabels() throws Exception { DataSetLookupConstraints constraints = new DataSetLookupConstraints() .setColumnTypes(new ColumnType[] {LABEL, LABEL}) .setGroupRequired(true); DataSetLookup lookup = constraints.newDataSetLookup(dataSet.getMetadata()); assertThat(constraints.check(lookup)).isNull(); DataSet result = dataSetManager.lookupDataSet(lookup); assertDataSetValues(result, dataSetFormatter, new String[][]{ {"Barcelona", "Engineering"}, {"Madrid", "Services"}, {"Brno", "Support"}, {"Westford", "Engineering"}, {"Raleigh", "Management"}, {"London", "Engineering"} }, 0); }