Search in sources :

Example 1 with CreatedRadiator

use of com.paulhammant.buildradiator.radiator.model.CreatedRadiator in project BuildRadiator by BuildRadiator.

the class RadiatorIntegrationTest method radiatorCanBeCreatedWithStepNamesThatAreNotTooLong.

@Test
public void radiatorCanBeCreatedWithStepNamesThatAreNotTooLong() {
    app = new TestVersionOfBuildRadiatorApp(null);
    startApp();
    CreatedRadiator createdRadiator = new CreatedRadiator();
    given().params("stepNames", join(",", "short1", "short 2", "short 333")).when().post(CONTRIVED_PATH_FOR_TESTING + "/create").then().statusCode(200).body(captureCreatedRadiator(createdRadiator));
    Radiator rad = app.getResultsStore().actualRadiators.values().iterator().next();
    assertThat(rad.code, equalTo(createdRadiator.code));
    assertThat(rad.secret, equalTo(createdRadiator.secret));
    assertThat(rad.stepNames, equalTo(stepNames("short1", "short 2", "short 333")));
}
Also used : CreatedRadiator(com.paulhammant.buildradiator.radiator.model.CreatedRadiator) HasNewRadiator.captureCreatedRadiator(com.paulhammant.buildradiator.radiator.hamcrest.HasNewRadiator.captureCreatedRadiator) Radiator(com.paulhammant.buildradiator.radiator.model.Radiator) CreatedRadiator(com.paulhammant.buildradiator.radiator.model.CreatedRadiator) HasNewRadiator.captureCreatedRadiator(com.paulhammant.buildradiator.radiator.hamcrest.HasNewRadiator.captureCreatedRadiator) Test(org.junit.Test)

Example 2 with CreatedRadiator

use of com.paulhammant.buildradiator.radiator.model.CreatedRadiator in project BuildRadiator by BuildRadiator.

the class RadiatorIntegrationTest method radiatorCanBeCreatedAndTransformUnderscoresInStepNames.

@Test
public void radiatorCanBeCreatedAndTransformUnderscoresInStepNames() {
    app = new TestVersionOfBuildRadiatorApp(null);
    startApp();
    CreatedRadiator createdRadiator = new CreatedRadiator();
    given().params("stepNames", join(",", "P_P", "Q q", "R-R")).when().post(CONTRIVED_PATH_FOR_TESTING + "/create").then().statusCode(200).body(captureCreatedRadiator(createdRadiator));
    Radiator rad = app.getResultsStore().actualRadiators.values().iterator().next();
    assertThat(rad.code, equalTo(createdRadiator.code));
    assertThat(rad.secret, equalTo(createdRadiator.secret));
    assertThat(rad.stepNames, equalTo(stepNames("P P", "Q q", "R-R")));
}
Also used : CreatedRadiator(com.paulhammant.buildradiator.radiator.model.CreatedRadiator) HasNewRadiator.captureCreatedRadiator(com.paulhammant.buildradiator.radiator.hamcrest.HasNewRadiator.captureCreatedRadiator) Radiator(com.paulhammant.buildradiator.radiator.model.Radiator) CreatedRadiator(com.paulhammant.buildradiator.radiator.model.CreatedRadiator) HasNewRadiator.captureCreatedRadiator(com.paulhammant.buildradiator.radiator.hamcrest.HasNewRadiator.captureCreatedRadiator) Test(org.junit.Test)

Example 3 with CreatedRadiator

use of com.paulhammant.buildradiator.radiator.model.CreatedRadiator in project BuildRadiator by BuildRadiator.

the class HasNewRadiator method captureCreatedRadiator.

public static BaseMatcher<String> captureCreatedRadiator(CreatedRadiator createdRadiator) {
    return new BaseMatcher<String>() {

        @Override
        public boolean matches(Object o) {
            try {
                CreatedRadiator cr = new ObjectMapper().readValue((String) o, CreatedRadiator.class);
                createdRadiator.code = cr.code;
                createdRadiator.secret = cr.secret;
            } catch (IOException e) {
                System.out.println("Error: Jackson couldn't parse JSON into 'CreatedRadiator' instance: " + o);
                return false;
            }
            return true;
        }

        @Override
        public void describeTo(Description description) {
        }
    };
}
Also used : Description(org.hamcrest.Description) BaseMatcher(org.hamcrest.BaseMatcher) IOException(java.io.IOException) CreatedRadiator(com.paulhammant.buildradiator.radiator.model.CreatedRadiator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

CreatedRadiator (com.paulhammant.buildradiator.radiator.model.CreatedRadiator)3 HasNewRadiator.captureCreatedRadiator (com.paulhammant.buildradiator.radiator.hamcrest.HasNewRadiator.captureCreatedRadiator)2 Radiator (com.paulhammant.buildradiator.radiator.model.Radiator)2 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 BaseMatcher (org.hamcrest.BaseMatcher)1 Description (org.hamcrest.Description)1