Implement toString method for ServerNode class and add unit tests for its output
This commit is contained in:
@@ -71,6 +71,28 @@ public class ServerNode {
|
||||
return Distribution.getPositiveSample(this.unavailable, rng);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
var build = new StringBuilder()
|
||||
.append(this.name)
|
||||
.append("[servers:")
|
||||
.append(this.maxServers)
|
||||
.append(", queue:")
|
||||
.append(this.maxQueue)
|
||||
.append(", spawn:")
|
||||
.append(this.spawnArrivals)
|
||||
.append(", ")
|
||||
.append(Distribution.toString(this.service));
|
||||
if (this.unavailable != null)
|
||||
build.append(", u:").append(Distribution.toString(this.unavailable));
|
||||
return build.append(']').toString();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof ServerNode))
|
||||
|
||||
Reference in New Issue
Block a user