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

Further tests

parent 303bb5e9
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.diagnosis.common.model;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
public final class PropertiesModelTest {
@Test
public void transactionalSettingShouldWork() {
final BooleanObserver observer = new BooleanObserver();
final PropertiesModel model = new PropertiesModel();
model.addObserver(observer);
model.startModification();
model.setTimeunit(TimeUnit.NANOSECONDS);
assertThat(observer.isFlag(), is(false));
model.commitModification();
assertThat(observer.isFlag(), is(true));
}
@Test
public void usualSettingShouldNotifyObservers() {
final BooleanObserver observer = new BooleanObserver();
final PropertiesModel model = new PropertiesModel();
model.addObserver(observer);
model.setTimeunit(TimeUnit.NANOSECONDS);
assertThat(observer.isFlag(), is(true));
}
@Test
public void settingShouldBePersisted() {
final PropertiesModel fstModel = new PropertiesModel();
fstModel.setTimeunit(TimeUnit.NANOSECONDS);
fstModel.setTimeunit(TimeUnit.MICROSECONDS);
final PropertiesModel sndModel = new PropertiesModel();
assertThat(sndModel.getTimeunit(), is(TimeUnit.MICROSECONDS));
}
private static class BooleanObserver implements Observer {
private boolean flag = false;
@Override
public void update(final Observable o, final Object arg) {
this.flag = true;
}
public boolean isFlag() {
return this.flag;
}
}
}
/***************************************************************************
* 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.diagnosis.common.model.importer.stages;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import java.util.Arrays;
import kieker.diagnosis.common.domain.AggregatedTrace;
import kieker.diagnosis.common.domain.OperationCall;
import kieker.diagnosis.common.domain.Trace;
import org.junit.Test;
public final class AggregatedTraceStatisticsDecoratorTest {
@Test
public void minMaxMeanAndAvgCalculationForSingleCallShouldWork() throws Exception {
final OperationCall call1 = new OperationCall("", "", "", 43);
final OperationCall call2 = new OperationCall("", "", "", 44);
final OperationCall call3 = new OperationCall("", "", "", 45);
call1.setDuration(15);
call2.setDuration(7);
call3.setDuration(44);
final Trace trace1 = new Trace(call1, 43);
final Trace trace2 = new Trace(call2, 44);
final Trace trace3 = new Trace(call3, 45);
final AggregatedTrace trace = new AggregatedTrace(Arrays.asList(trace1, trace2, trace3));
final AggregatedTraceStatisticsDecorator decorator = new AggregatedTraceStatisticsDecorator();
decorator.onStarting();
decorator.execute(trace);
assertThat(trace.getRootOperationCall().getMinDuration(), is(7L));
assertThat(trace.getRootOperationCall().getMaxDuration(), is(44L));
assertThat(trace.getRootOperationCall().getAvgDuration(), is(22L));
assertThat(trace.getRootOperationCall().getMeanDuration(), is(15L));
}
}
......@@ -24,7 +24,7 @@ import kieker.diagnosis.common.domain.Trace;
import org.junit.Test;
public class TraceStatisticsDecoratorTest {
public final class TraceStatisticsDecoratorTest {
@Test
public void percentCalculationShouldWork() throws Exception {
......
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