Search in sources :

Example 1 with Radiator

use of com.paulhammant.buildradiator.model.Radiator 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 Radiator

use of com.paulhammant.buildradiator.model.Radiator in project BuildRadiator by BuildRadiator.

the class RadiatorStoreUnitTest method radiatorCanBeRetrieved.

@Test
public void radiatorCanBeRetrieved() {
    RadiatorStore rs = new RadiatorStore();
    Radiator rad = null;
    try {
        rad = rs.get("AAA", "127.0.0.1");
        fail();
    } catch (RadiatorDoesntExist e) {
    // expected
    }
    rs.createRadiator(new TestRandomGenerator("AAA", "sseeccrreett"), "A");
    rad = rs.get("AAA", "127.0.0.1");
    assertThat(rad.code, equalTo("AAA"));
}
Also used : RadiatorDoesntExist(com.paulhammant.buildradiator.model.RadiatorDoesntExist) Radiator(com.paulhammant.buildradiator.model.Radiator) Test(org.junit.Test)

Example 3 with Radiator

use of com.paulhammant.buildradiator.model.Radiator in project BuildRadiator by BuildRadiator.

the class RadiatorStoreUnitTest method saverThreadShouldDoItsBusinessForUnsavedRadiatorTwiceIfNeeded.

@Test
public void saverThreadShouldDoItsBusinessForUnsavedRadiatorTwiceIfNeeded() throws InterruptedException {
    saverThreadShouldDoItsBusinessForUnsavedRadiatorJustOnce();
    Radiator rad = radStore.get("QWERTY", "127.0.0.1");
    rad.lastUpdated = System.currentTimeMillis();
    Thread.sleep(4);
    assertThat(called, equalTo(2));
}
Also used : Radiator(com.paulhammant.buildradiator.model.Radiator) Test(org.junit.Test)

Example 4 with Radiator

use of com.paulhammant.buildradiator.model.Radiator in project BuildRadiator by BuildRadiator.

the class RadiatorStoreUnitTest method unknownRadiatorShouldBeSoughtFromDataServiceJustOnce.

@Test
public void unknownRadiatorShouldBeSoughtFromDataServiceJustOnce() throws InterruptedException {
    radStore = getTestAwareRadiatorStore();
    Radiator r = radStore.createRadiator(new TestRandomGenerator("QWERTY", "sseeccrreett"), "A");
    assertQwertyRadiatorHasBeenCalledOnce();
}
Also used : Radiator(com.paulhammant.buildradiator.model.Radiator) Test(org.junit.Test)

Example 5 with Radiator

use of com.paulhammant.buildradiator.model.Radiator in project BuildRadiator by BuildRadiator.

the class RadiatorStoreUnitTest method radiatorCanBeCreatedWithGoodIpAddresses.

@Test
public void radiatorCanBeCreatedWithGoodIpAddresses() {
    Radiator rad = new RadiatorStore().createRadiator(new TestRandomGenerator("QWERTY", "sseeccrreett"), "A").withIpAccessRestrictedToThese("123.123.123.122", "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
    assertThat(rad.code, equalTo("QWERTY"));
    assertThat(rad.codeAndSecretOnly().code, equalTo("QWERTY"));
    assertThat(rad.codeAndSecretOnly().secret, equalTo("sseeccrreett"));
}
Also used : Radiator(com.paulhammant.buildradiator.model.Radiator) Test(org.junit.Test)

Aggregations

Radiator (com.paulhammant.buildradiator.model.Radiator)27 Test (org.junit.Test)21 HasNewRadiator.captureCreatedRadiator (com.paulhammant.buildradiator.hamcrest.HasNewRadiator.captureCreatedRadiator)14 CreatedRadiator (com.paulhammant.buildradiator.model.CreatedRadiator)14 Step (com.paulhammant.buildradiator.model.Step)4 ByteString (com.google.protobuf.ByteString)2 Build (com.paulhammant.buildradiator.model.Build)2 RadiatorDoesntExist (com.paulhammant.buildradiator.model.RadiatorDoesntExist)2 UnknownStep (com.paulhammant.buildradiator.model.UnknownStep)1