Search in sources :

Example 1 with CdmaMastSegment

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

the class CdmaMastSegmentTest method testSegmentNameDefaultIsLastItem.

@Test
public void testSegmentNameDefaultIsLastItem() {
    final CdmaMastSegment mastSegmentDefault = new CdmaMastSegment(CdmaMastSegment.DEFAULT_MASTSEGMENT);
    final CdmaMastSegment mastSegmentNormal = new CdmaMastSegment("zzzMast");
    assertThat(mastSegmentDefault.compareTo(mastSegmentNormal) > 0).withFailMessage("An empty mast segment should be bigger than all other mast segments").isTrue();
}
Also used : CdmaMastSegment(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment) Test(org.junit.jupiter.api.Test)

Example 2 with CdmaMastSegment

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment 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 3 with CdmaMastSegment

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

the class CdmaRunTest method itemPerMastSegment.

@Test
public void itemPerMastSegment() {
    final CdmaRun run = new CdmaRun();
    for (int i = 0; i < 5; i++) {
        run.add(new CdmaDevice("cd" + i, this.loopbackAddress, "200/" + i, (short) 1));
    }
    final Iterator<CdmaMastSegment> iterator = run.getMastSegmentIterator();
    for (int i = 0; i < 5; i++) {
        iterator.next();
    }
    assertThat(iterator.hasNext()).withFailMessage("Iterator should not have any items left").isFalse();
}
Also used : CdmaMastSegment(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment) CdmaRun(org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun) CdmaDevice(org.opensmartgridplatform.domain.core.valueobjects.CdmaDevice) Test(org.junit.jupiter.api.Test)

Example 4 with CdmaMastSegment

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment 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 5 with CdmaMastSegment

use of org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment 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)

Aggregations

Test (org.junit.jupiter.api.Test)7 CdmaMastSegment (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaMastSegment)7 CdmaBatchDevice (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatchDevice)4 CdmaBatch (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaBatch)2 CdmaRun (org.opensmartgridplatform.adapter.domain.publiclighting.application.valueobjects.CdmaRun)1 CdmaDevice (org.opensmartgridplatform.domain.core.valueobjects.CdmaDevice)1