Search in sources :

Example 1 with CdmaBatchDevice

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice in project open-smart-grid-platform by OSGP.

the class CdmaMastSegmentTest method newBatchNumberNull.

@Test
public void newBatchNumberNull() {
    final CdmaMastSegment mastSegment = new CdmaMastSegment("200/1");
    final CdmaBatchDevice cd1 = new CdmaBatchDevice("cd1", this.loopbackAddress);
    mastSegment.addCdmaBatchDevice(null, cd1);
    final CdmaBatch cdmaBatch = mastSegment.popCdmaBatch();
    assertThat(cdmaBatch.getBatchNumber()).withFailMessage("Batch should get maximum batch number").isEqualTo(CdmaBatch.MAX_BATCH_NUMBER);
}
Also used : CdmaMastSegment(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment) CdmaBatchDevice(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice) CdmaBatch(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatch) Test(org.junit.jupiter.api.Test)

Example 2 with CdmaBatchDevice

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice in project open-smart-grid-platform by OSGP.

the class CdmaMastSegmentTest method testPopBatches.

@Test
public void testPopBatches() {
    final CdmaMastSegment mastSegment = new CdmaMastSegment("200/55");
    for (short i = 0; i < 10; i++) {
        // Each device has a different batch
        mastSegment.addCdmaBatchDevice(i, new CdmaBatchDevice("cd" + i, this.loopbackAddress));
    }
    for (int batchNo = 0; batchNo < 10; batchNo++) {
        assertThat(mastSegment.empty()).withFailMessage("There should be at least one CdmaBatch left").isFalse();
        mastSegment.popCdmaBatch();
    }
    assertThat(mastSegment.empty()).withFailMessage("All CdmaBatches should have been removed by now").isTrue();
}
Also used : CdmaMastSegment(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment) CdmaBatchDevice(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice) Test(org.junit.jupiter.api.Test)

Example 3 with CdmaBatchDevice

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice in project open-smart-grid-platform by OSGP.

the class CdmaMastSegmentTest method popCdmaBatch.

@Test
public void popCdmaBatch() {
    final CdmaMastSegment mastSegment = new CdmaMastSegment("200/1");
    final CdmaBatchDevice cd1 = new CdmaBatchDevice("cd1", this.loopbackAddress);
    mastSegment.addCdmaBatchDevice((short) 1, cd1);
    final CdmaBatchDevice cd2 = new CdmaBatchDevice("cd2", this.loopbackAddress);
    mastSegment.addCdmaBatchDevice((short) 1, cd2);
    final CdmaBatch batch = mastSegment.popCdmaBatch();
    assertThat(batch.getCdmaBatchDevices().size()).isEqualTo(2);
    // popCdmaBatch should remove the batch from the mast segment,
    // there should be no more batch left in the mast segment.
    assertThat(mastSegment.empty()).withFailMessage("MastSegment should not contain any devices").isTrue();
}
Also used : CdmaMastSegment(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment) CdmaBatchDevice(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice) CdmaBatch(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatch) Test(org.junit.jupiter.api.Test)

Example 4 with CdmaBatchDevice

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice in project open-smart-grid-platform by OSGP.

the class CdmaMastSegmentTest method newCdmaMastSegment.

@Test
public void newCdmaMastSegment() {
    final CdmaMastSegment mastSegment = new CdmaMastSegment("200/1");
    final CdmaBatchDevice cd1 = new CdmaBatchDevice("cd1", this.loopbackAddress);
    mastSegment.addCdmaBatchDevice((short) 1, cd1);
    assertThat(mastSegment.getMastSegment()).isEqualTo("200/1");
    assertThat(mastSegment.empty()).withFailMessage("MastSegment should contain 1 device").isFalse();
}
Also used : CdmaMastSegment(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment) CdmaBatchDevice(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice) Test(org.junit.jupiter.api.Test)

Example 5 with CdmaBatchDevice

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice in project open-smart-grid-platform by OSGP.

the class CdmaBatchTest method newCdmaBatch.

@Test
public void newCdmaBatch() {
    final CdmaBatch batch = new CdmaBatch((short) 1);
    final CdmaBatchDevice cd1 = new CdmaBatchDevice("cd1", this.loopbackAddress);
    batch.addCdmaBatchDevice(cd1);
    final CdmaBatchDevice cd2 = new CdmaBatchDevice("cd2", this.loopbackAddress);
    batch.addCdmaBatchDevice(cd2);
    assertThat(batch.getBatchNumber()).isEqualTo(Short.valueOf((short) 1));
    assertThat(batch.getCdmaBatchDevices().size()).withFailMessage("Batch should contain 2 devices").isEqualTo(2);
}
Also used : CdmaBatchDevice(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice) CdmaBatch(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatch) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)5 CdmaBatchDevice (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice)5 CdmaMastSegment (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment)4 CdmaBatch (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatch)3