Skip to content
Snippets Groups Projects
Commit 29b91d07 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Additional tests; removed the deprecated record class

parent 7a0d8061
No related branches found
No related tags found
No related merge requests found
/***************************************************************************
* 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;
}
}
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();
}
package kieker.gui.common.domain;
public final class AggregatedExecutionTest extends AbstractExecutionTest<AggregatedExecution> {
@Override
protected AggregatedExecution createEmptyExecution() {
return new AggregatedExecution(new Execution(0, "", "", ""));
}
}
package kieker.gui.common.domain;
public final class ExecutionTest extends AbstractExecutionTest<Execution> {
@Override
protected Execution createEmptyExecution() {
return new Execution(0, "", "", "");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment