From 29b91d07e349e355448c0b76e6fe325f767dedb9 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Thu, 29 Jan 2015 17:42:04 +0100 Subject: [PATCH] Additional tests; removed the deprecated record class --- .../java/kieker/gui/common/domain/Record.java | 48 ----------------- .../common/domain/AbstractExecutionTest.java | 52 +++++++++++++++++++ .../domain/AggregatedExecutionTest.java | 10 ++++ .../gui/common/domain/ExecutionTest.java | 10 ++++ 4 files changed, 72 insertions(+), 48 deletions(-) delete mode 100644 src/main/java/kieker/gui/common/domain/Record.java create mode 100644 src/test/java/kieker/gui/common/domain/AbstractExecutionTest.java create mode 100644 src/test/java/kieker/gui/common/domain/AggregatedExecutionTest.java create mode 100644 src/test/java/kieker/gui/common/domain/ExecutionTest.java diff --git a/src/main/java/kieker/gui/common/domain/Record.java b/src/main/java/kieker/gui/common/domain/Record.java deleted file mode 100644 index cfbfdfe3..00000000 --- a/src/main/java/kieker/gui/common/domain/Record.java +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright 2014 Kieker Project (http://kieker-monitoring.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ***************************************************************************/ - -package kieker.gui.common.domain; - -/** - * A simplified representation of a monitoring record. - * - * @author Nils Christian Ehmke - */ -public final class Record { - - private final long timestamp; - private final String type; - private final String representation; - - public Record(final long timestamp, final String type, final String representation) { - this.timestamp = timestamp; - this.type = type; - this.representation = representation; - } - - public long getTimestamp() { - return this.timestamp; - } - - public String getType() { - return this.type; - } - - public String getRepresentation() { - return this.representation; - } - -} diff --git a/src/test/java/kieker/gui/common/domain/AbstractExecutionTest.java b/src/test/java/kieker/gui/common/domain/AbstractExecutionTest.java new file mode 100644 index 00000000..6b878661 --- /dev/null +++ b/src/test/java/kieker/gui/common/domain/AbstractExecutionTest.java @@ -0,0 +1,52 @@ +package kieker.gui.common.domain; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public abstract class AbstractExecutionTest<T extends AbstractExecution<T>> { + + @Test + public void traceDepthCalculationInCommonCaseShouldWork() { + final AbstractExecution<T> execution = this.createEmptyExecution(); + + execution.addExecutionEntry(this.createEmptyExecution()); + execution.addExecutionEntry(this.createEmptyExecution()); + execution.addExecutionEntry(this.createEmptyExecution()); + + execution.children.get(0).addExecutionEntry(this.createEmptyExecution()); + + assertThat(execution.getTraceDepth(), is(2)); + } + + @Test + public void traceDepthCalculationForNoChildrenShouldWork() { + final AbstractExecution<T> execution = this.createEmptyExecution(); + + assertThat(execution.getTraceDepth(), is(0)); + } + + @Test + public void traceSizeCalculationInCommonCaseShouldWork() { + final AbstractExecution<T> execution = this.createEmptyExecution(); + + execution.addExecutionEntry(this.createEmptyExecution()); + execution.addExecutionEntry(this.createEmptyExecution()); + execution.addExecutionEntry(this.createEmptyExecution()); + + execution.children.get(0).addExecutionEntry(this.createEmptyExecution()); + + assertThat(execution.getTraceSize(), is(5)); + } + + @Test + public void traceSizeCalculationForNoChildrenShouldWork() { + final AbstractExecution<T> execution = this.createEmptyExecution(); + + assertThat(execution.getTraceSize(), is(1)); + } + + protected abstract T createEmptyExecution(); + +} diff --git a/src/test/java/kieker/gui/common/domain/AggregatedExecutionTest.java b/src/test/java/kieker/gui/common/domain/AggregatedExecutionTest.java new file mode 100644 index 00000000..2c4923e2 --- /dev/null +++ b/src/test/java/kieker/gui/common/domain/AggregatedExecutionTest.java @@ -0,0 +1,10 @@ +package kieker.gui.common.domain; + +public final class AggregatedExecutionTest extends AbstractExecutionTest<AggregatedExecution> { + + @Override + protected AggregatedExecution createEmptyExecution() { + return new AggregatedExecution(new Execution(0, "", "", "")); + } + +} diff --git a/src/test/java/kieker/gui/common/domain/ExecutionTest.java b/src/test/java/kieker/gui/common/domain/ExecutionTest.java new file mode 100644 index 00000000..dae8de9b --- /dev/null +++ b/src/test/java/kieker/gui/common/domain/ExecutionTest.java @@ -0,0 +1,10 @@ +package kieker.gui.common.domain; + +public final class ExecutionTest extends AbstractExecutionTest<Execution> { + + @Override + protected Execution createEmptyExecution() { + return new Execution(0, "", "", ""); + } + +} -- GitLab