PutInputValidatorTestExpander

Expands:


    $componentRoot.directory$/$layerDir$/gen_test/jaxrs/src/$dataElement.packageName;format="toPath"$/validation/$dataElement.name;format="firstToLower"$
  /$dataElement.name$PutInputValidatorTest.java

if:

dataElement.component.getOption('enableJaxrs').defined and
    dataElement.component.getOption('enableValidation').defined and
    dataElement.getOption('includeJaxrsConnector').defined and
    dataElement.getOption('exposePutEndpoint').defined
property value
element type DataElement
qualified name net.democritus.expander.rest.control.test.PutInputValidatorTestExpander
layer CONTROL_LAYER
technology JAXRS
sourceType JAVA
phase expansion
features  

Example

Some example of the content generated by the expander:

// expanded with nsx-expanders:4.16.3, expansionResource net.democritus:rest-expanders:2.4.2
package com.example.city.validation.city;

import com.example.city.model.city.CityPutInputModel;

import cities.validation.ValidationResult;

import net.democritus.sys.Context;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;


import static cities.ValidationErrorMatchers.validationError;
import static cities.validation.ValidationError.*;

import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;

// @anchor:imports:start
// @anchor:imports:end
// anchor:custom-imports:start
// anchor:custom-imports:end

public class CityPutInputValidatorTest {

  private CityPutInputValidator validator;
  private CityPutInputModel model;

  // @anchor:fields:start
  // @anchor:fields:end
  // anchor:custom-fields:start
  // anchor:custom-fields:end

  @Before
  public void before() {
    validator = new CityPutInputValidator(Context.emptyContext());
    model = new CityPutInputModel();

    // @anchor:before:start
    // @anchor:before:end
    // anchor:custom-before:start
    // anchor:custom-before:end
  }

  @After
  public void after() {
    // @anchor:after:start
    // @anchor:after:end
    // anchor:custom-after:start
    // anchor:custom-after:end
  }

  @Test
  public void successNameIsRequired() {
    model.setName("name");

    final ValidationResult result = validator.validate(model);
    assertThat(result.getErrors("name"),
        not(hasItem(validationError(MISSING_REQUIRED_VALUE))));
  }

  @Test
  public void failNameIsRequired() {
    model.setName(null);

    final ValidationResult result = validator.validate(model);
    assertThat(result.getErrors("name"),
        hasItem(validationError(MISSING_REQUIRED_VALUE)));
  }

  @Test
  public void successPostalCodeIsRequired() {
    model.setPostalCode(123);

    final ValidationResult result = validator.validate(model);
    assertThat(result.getErrors("postalCode"),
        not(hasItem(validationError(MISSING_REQUIRED_VALUE))));
  }

  @Test
  public void failPostalCodeIsRequired() {
    model.setPostalCode(null);

    final ValidationResult result = validator.validate(model);
    assertThat(result.getErrors("postalCode"),
        hasItem(validationError(MISSING_REQUIRED_VALUE)));
  }

  @Test
  public void successCountryIsRequired() {
    model.setCountry("country");

    final ValidationResult result = validator.validate(model);
    assertThat(result.getErrors("country"),
        not(hasItem(validationError(MISSING_REQUIRED_VALUE))));
  }

  @Test
  public void failCountryIsRequired() {
    model.setCountry(null);

    final ValidationResult result = validator.validate(model);
    assertThat(result.getErrors("country"),
        hasItem(validationError(MISSING_REQUIRED_VALUE)));
  }

  // @anchor:methods:start
  // @anchor:methods:end
  // anchor:custom-methods:start
  // anchor:custom-methods:end

}

These expanders have the same isApplicable as PutInputValidatorTestExpander.