BundleCondition extends BasicCondition<Bundle, BundleCondition> implements BundleChecks<BundleCondition> { @NonNull @Override public BundleCondition containsKey(@NonNull String key) { require(subject).isNotNull(); if (!subject.containsKey(key)) { DbcAssertionError.throwNew(new IllegalStateException("Expected bundle to contain key<" + key + ">"), this.message); } return result(); } BundleCondition(Bundle subject); @NonNull @Override BundleCondition containsKey(@NonNull String key); @NonNull @Override BundleCondition valueIsOfType(@NonNull String key, @NonNull Class<?> type);  }
@Test public void containsKey() throws Exception { Bundle subject = new Bundle(); subject.putString("KEY", "VALUE"); BundleCondition condition = new BundleCondition(subject); condition.containsKey("KEY"); Assertions.assertThatThrownBy(() -> condition.containsKey("FAIL")) .isInstanceOf(DbcAssertionError.class) .hasCauseInstanceOf(IllegalStateException.class); }