/** Validate that no errors appear when no conflict occurs */
 @Test
 public void testGoodInventoryNumber() {
   final String invNumber = "INV-12345";
   fixture.setInventoryNumber(invNumber);
   context.checking(
       new Expectations() {
         {
           oneOf(assetRepository).findAssetByInventoryNumber(invNumber);
           will(returnValue(null));
         }
       });
   rule.validate(fixture, errors);
   context.assertIsSatisfied();
 }
  /** Validate that a rejection occurs if a conflict occurs */
  @Test
  public void testConflictingInventoryNumber() {
    final Asset asset = new Asset();
    final String invNumber = "INV-12345";
    fixture.setInventoryNumber(invNumber);

    context.checking(
        new Expectations() {
          {
            oneOf(assetRepository).findAssetByInventoryNumber(invNumber);
            will(returnValue(asset));
            oneOf(errors).rejectValue("inventoryNumber", MSG_PREFIX + "inventoryNumber.conflict");
          }
        });

    rule.validate(fixture, errors);
    context.assertIsSatisfied();
  }
 /** Validate that nothing happens if an empty inventory number is provided */
 @Test
 public void testAllowsEmptyInventoryNumber() {
   rule.validate(fixture, errors);
 }