/**
  * empty property names.
  *
  * @throws Exception if occur
  */
 @Test
 public void name_empty() throws Exception {
   VerifyRule rule = rule("verify/name_empty.xls");
   assertThat(rule.verify(obj(1, "a"), obj(1, "a")), is(nullValue()));
   assertThat(rule.verify(obj(1, "a"), obj(1, "b")), is(nullValue()));
   assertThat(rule.verify(obj(1, "a"), obj(2, "b")), not(nullValue()));
 }
 /**
  * {@link NullityConditionKind} - accept present.
  *
  * @throws Exception if occur
  */
 @Test
 public void nullity_AP() throws Exception {
   VerifyRule rule = rule("verify/nullity_AP.xls");
   assertThat(rule.verify(obj(0, "a"), obj(0, "a")), is(nullValue()));
   assertThat(rule.verify(obj(0, null), obj(0, "a")), is(nullValue()));
   assertThat(rule.verify(obj(0, "a"), obj(0, null)), not(nullValue()));
   assertThat(rule.verify(obj(0, null), obj(0, null)), not(nullValue()));
 }
 /**
  * {@link ValueConditionKind} - contain.
  *
  * @throws Exception if occur
  */
 @Test
 public void value_contain() throws Exception {
   VerifyRule rule = rule("verify/value_contain.xls");
   assertThat(rule.verify(obj(0, "ab"), obj(0, "ab")), is(nullValue()));
   assertThat(rule.verify(obj(0, "ab"), obj(0, "aba")), is(nullValue()));
   assertThat(rule.verify(obj(0, "ab"), obj(0, "aca")), not(nullValue()));
   assertThat(rule.verify(obj(0, "ab"), obj(0, "a")), not(nullValue()));
 }
 /**
  * {@link DataModelCondition} - ignore all.
  *
  * @throws Exception if occur
  */
 @Test
 public void skip() throws Exception {
   VerifyRule rule = rule("verify/skip.xls");
   assertThat(rule.verify(obj(1, "a"), obj(1, "a")), is(nullValue()));
   assertThat(rule.verify(obj(1, "a"), obj(1, "b")), is(nullValue()));
   assertThat(rule.verify(null, obj(1, "a")), is(nullValue()));
   assertThat(rule.verify(obj(1, "a"), null), is(nullValue()));
 }
 /**
  * {@link DataModelCondition} - ignore unexpected.
  *
  * @throws Exception if occur
  */
 @Test
 public void ignore_unexpected() throws Exception {
   VerifyRule rule = rule("verify/ignore_unexpected.xls");
   assertThat(rule.verify(obj(1, "a"), obj(1, "a")), is(nullValue()));
   assertThat(rule.verify(obj(1, "a"), obj(1, "b")), not(nullValue()));
   assertThat(rule.verify(null, obj(1, "a")), is(nullValue()));
   assertThat(rule.verify(obj(1, "a"), null), not(nullValue()));
 }
 /**
  * {@link ValueConditionKind} - don't care.
  *
  * @throws Exception if occur
  */
 @Test
 public void value_any() throws Exception {
   VerifyRule rule = rule("verify/value_any.xls");
   assertThat(rule.verify(obj(1, "a"), obj(1, "a")), is(nullValue()));
   assertThat(rule.verify(obj(1, "a"), obj(2, "b")), is(nullValue()));
   assertThat(rule.verify(obj(1, "a"), obj(null, null)), is(nullValue()));
   assertThat(rule.verify(null, obj(1, "a")), not(nullValue()));
   assertThat(rule.verify(obj(1, "a"), null), not(nullValue()));
 }
 /**
  * {@link DataModelCondition} - ignore all.
  *
  * @throws Exception if occur
  */
 @Test
 public void skip_key() throws Exception {
   VerifyRule rule = rule("verify/skip.xls");
   Object k0 = rule.getKey(obj(1, "a"));
   Object k1 = rule.getKey(obj(1, "a"));
   Object k2 = rule.getKey(obj(1, "a"));
   assertThat(k0, not(equalTo(k1)));
   assertThat(k0, not(equalTo(k2)));
   assertThat(k1, not(equalTo(k2)));
 }
  /**
   * integration test with test-data-generator.
   *
   * @throws Exception if occur
   */
  @Test
  public void integration() throws Exception {
    ExcelSheetRuleProvider provider = new ExcelSheetRuleProvider();
    VerifyRule rule = provider.get(SIMPLE, context(10), uri("it/simple.xls", ":2"));
    assertThat(rule, not(nullValue()));

    assertThat(rule.getKey(obj(100, "a")), equalTo(rule.getKey(obj(100, "b"))));
    assertThat(rule.getKey(obj(100, "a")), not(equalTo(rule.getKey(obj(200, "a")))));

    assertThat(rule.verify(obj(1, "a"), obj(2, "a")), is(nullValue()));
    assertThat(rule.verify(obj(1, "a"), obj(1, "b")), not(nullValue()));
  }
  /**
   * {@link ValueConditionKind} - expr.
   *
   * @throws Exception if occur
   */
  @Test
  public void value_expr() throws Exception {
    ExcelSheetRuleProvider provider = new ExcelSheetRuleProvider();
    VerifyRule rule = provider.get(SIMPLE, context(10), uri("verify/value_approx.xls", ":0"));
    assertThat(rule, not(nullValue()));

    assertThat(rule.verify(num(1, 1.0), num(1, 1.0)), is(nullValue()));
    assertThat(rule.verify(num(1, 1.0), num(1, 1.49)), is(nullValue()));
    assertThat(rule.verify(num(1, 1.0), num(1, 1.51)), is(notNullValue()));
    assertThat(rule.verify(num(1, 1.0), num(1, 0.51)), is(nullValue()));
    assertThat(rule.verify(num(1, 1.0), num(1, 0.49)), is(notNullValue()));
  }
  /**
   * simple verification via SPI.
   *
   * @throws Exception if occur
   */
  @Test
  public void spi() throws Exception {
    VerifyRuleProvider provider =
        new SpiVerifyRuleProvider(ExcelSheetRuleProvider.class.getClassLoader());
    VerifyRule rule = provider.get(SIMPLE, context(10), uri("verify/simple.xls", ":0"));
    assertThat(rule, not(nullValue()));

    assertThat(rule.getKey(obj(100, "a")), equalTo(rule.getKey(obj(100, "b"))));
    assertThat(rule.getKey(obj(100, "a")), not(equalTo(rule.getKey(obj(200, "a")))));

    assertThat(rule.verify(obj(1, "a"), obj(2, "a")), is(nullValue()));
    assertThat(rule.verify(obj(1, "a"), obj(1, "b")), not(nullValue()));
  }
  /**
   * {@link ValueConditionKind} - today (but test was started yesterday).
   *
   * @throws Exception if occur
   */
  @Test
  public void value_today_started_yesterday() throws Exception {
    // 2011/03/31 23:00:00 -> 2011/04/01 0:30:00
    VerifyContext context = context(90);
    VerifyRule rule = rule("verify/value_today.xls", context);

    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.set(2011, 2, 30);
    assertThat(rule.verify(obj(0, ""), date(calendar)), not(nullValue()));
    calendar.set(2011, 2, 31);
    assertThat(rule.verify(obj(0, ""), date(calendar)), is(nullValue()));
    calendar.set(2011, 3, 1);
    assertThat(rule.verify(obj(0, ""), date(calendar)), is(nullValue()));
    calendar.set(2011, 3, 2);
    assertThat(rule.verify(obj(0, ""), date(calendar)), not(nullValue()));
  }
  /**
   * {@link ValueConditionKind} - keys.
   *
   * @throws Exception if occur
   */
  @Test
  public void value_keys() throws Exception {
    VerifyRule rule = rule("verify/value_keys.xls");
    assertThat(rule.getKey(obj(1, "a")), equalTo(rule.getKey(obj(1, "a"))));
    assertThat(rule.getKey(obj(2, "b")), equalTo(rule.getKey(obj(2, "b"))));
    assertThat(rule.getKey(obj(1, "a")), not(equalTo(rule.getKey(obj(2, "a")))));
    assertThat(rule.getKey(obj(1, "a")), not(equalTo(rule.getKey(obj(1, "b")))));

    assertThat(rule.verify(obj(1, "a"), obj(1, "a")), is(nullValue()));
    assertThat(rule.verify(obj(1, "a"), obj(2, "b")), is(nullValue()));
    assertThat(rule.verify(null, obj(1, "a")), not(nullValue()));
    assertThat(rule.verify(obj(1, "a"), null), not(nullValue()));
  }
  /**
   * {@link ValueConditionKind} - now.
   *
   * @throws Exception if occur
   */
  @Test
  public void value_now() throws Exception {
    // 2011/03/31 23:00:00 -> 23:30:00
    VerifyContext context = context(30);
    VerifyRule rule = rule("verify/value_now.xls", context);

    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.set(2011, 2, 31, 0, 0, 0);
    assertThat(rule.verify(obj(0, ""), datetime(calendar)), not(nullValue()));
    calendar.set(2011, 2, 31, 22, 59, 59);
    assertThat(rule.verify(obj(0, ""), datetime(calendar)), not(nullValue()));
    calendar.set(2011, 2, 31, 23, 0, 0);
    assertThat(rule.verify(obj(0, ""), datetime(calendar)), is(nullValue()));
    calendar.set(2011, 2, 31, 23, 15, 0);
    assertThat(rule.verify(obj(0, ""), datetime(calendar)), is(nullValue()));
    calendar.set(2011, 2, 31, 23, 30, 00);
    assertThat(rule.verify(obj(0, ""), datetime(calendar)), is(nullValue()));
    calendar.set(2011, 2, 31, 23, 30, 01);
    assertThat(rule.verify(obj(0, ""), datetime(calendar)), not(nullValue()));
    calendar.set(2011, 2, 31, 23, 45, 00);
    assertThat(rule.verify(obj(0, ""), datetime(calendar)), not(nullValue()));
  }