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();
}
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);
}
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();
}
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();
}
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();
}
Aggregations