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

Added further JUnit tests

parent 33300bf2
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.importer.stages;
import static org.hamcrest.Matchers.is;
......
/***************************************************************************
* 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.util;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class MapperTest {
@Test
public void mappingWithoutEntriesShouldNotLeadToException() {
final Mapper<Integer, String> mapper = new Mapper<>();
assertThat(mapper.resolve(1), is(nullValue()));
}
@Test
public void mappingWithSingleEntryShouldWork() {
final Mapper<Integer, String> mapper = new Mapper<>();
mapper.map(1).to("One");
assertThat(mapper.resolve(1), is("One"));
}
@Test
public void mappingWithMultipleEntriesShouldWork() {
final Mapper<Integer, String> mapper = new Mapper<>();
mapper.map(1).to("One");
mapper.map(2).to("Two");
assertThat(mapper.resolve(1), is("One"));
}
@Test
public void sameKeyShouldOverwriteMapping() {
final Mapper<Integer, String> mapper = new Mapper<>();
mapper.map(1).to("One");
mapper.map(1).to("1");
assertThat(mapper.resolve(1), is("1"));
}
@Test
public void reverseMappingShouldWork() {
final Mapper<Integer, String> mapper = new Mapper<>();
mapper.map(1).to("One");
assertThat(mapper.invertedResolve("One"), is(1));
}
}
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