Search in sources :

Example 1 with CreatedRadiator

use of com.paulhammant.buildradiator.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("/r/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 : HasNewRadiator.captureCreatedRadiator(com.paulhammant.buildradiator.hamcrest.HasNewRadiator.captureCreatedRadiator) CreatedRadiator(com.paulhammant.buildradiator.model.CreatedRadiator) HasNewRadiator.captureCreatedRadiator(com.paulhammant.buildradiator.hamcrest.HasNewRadiator.captureCreatedRadiator) Radiator(com.paulhammant.buildradiator.model.Radiator) CreatedRadiator(com.paulhammant.buildradiator.model.CreatedRadiator) Test(org.junit.Test)

Example 2 with CreatedRadiator

use of com.paulhammant.buildradiator.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) {
                fail("IOE encountered " + e.getMessage());
            }
            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.model.CreatedRadiator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with CreatedRadiator

use of com.paulhammant.buildradiator.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("/r/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 : HasNewRadiator.captureCreatedRadiator(com.paulhammant.buildradiator.hamcrest.HasNewRadiator.captureCreatedRadiator) CreatedRadiator(com.paulhammant.buildradiator.model.CreatedRadiator) HasNewRadiator.captureCreatedRadiator(com.paulhammant.buildradiator.hamcrest.HasNewRadiator.captureCreatedRadiator) Radiator(com.paulhammant.buildradiator.model.Radiator) CreatedRadiator(com.paulhammant.buildradiator.model.CreatedRadiator) Test(org.junit.Test)

Aggregations

CreatedRadiator (com.paulhammant.buildradiator.model.CreatedRadiator)3 HasNewRadiator.captureCreatedRadiator (com.paulhammant.buildradiator.hamcrest.HasNewRadiator.captureCreatedRadiator)2 Radiator (com.paulhammant.buildradiator.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