Search in sources :

Example 1 with RadiatorDoesntExist

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

the class RadiatorStore method get.

Radiator get(final String radCode, String ipAddress) {
    Radiator radiator = this.actualRadiators.get(radCode);
    if (radiator == null) {
        radiator = getFromDataService(radCode);
        if (radiator != null) {
            actualRadiators.put(radCode, radiator);
            radiatorLastSavedTimes.put(radCode, radiator.lastUpdated);
        }
    }
    if (radiator != null) {
        radiator.verifyIP(ipAddress);
    } else {
        throw new RadiatorDoesntExist();
    }
    return radiator;
}
Also used : RadiatorDoesntExist(com.paulhammant.buildradiator.radiator.model.RadiatorDoesntExist) Radiator(com.paulhammant.buildradiator.radiator.model.Radiator)

Example 2 with RadiatorDoesntExist

use of com.paulhammant.buildradiator.radiator.model.RadiatorDoesntExist 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.radiator.model.RadiatorDoesntExist) Radiator(com.paulhammant.buildradiator.radiator.model.Radiator) Test(org.junit.Test)

Aggregations

Radiator (com.paulhammant.buildradiator.radiator.model.Radiator)2 RadiatorDoesntExist (com.paulhammant.buildradiator.radiator.model.RadiatorDoesntExist)2 Test (org.junit.Test)1