Home | History | Annotate | Download | only in runtime
      1 /*******************************************************************************
      2  * Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors
      3  * All rights reserved. This program and the accompanying materials
      4  * are made available under the terms of the Eclipse Public License v1.0
      5  * which accompanies this distribution, and is available at
      6  * http://www.eclipse.org/legal/epl-v10.html
      7  *
      8  * Contributors:
      9  *    Marc R. Hoffmann - initial API and implementation
     10  *
     11  *******************************************************************************/
     12 package org.jacoco.core.runtime;
     13 
     14 import static org.junit.Assert.assertEquals;
     15 import static org.junit.Assert.assertSame;
     16 
     17 import java.util.HashMap;
     18 import java.util.Map;
     19 
     20 import org.jacoco.core.data.ExecutionData;
     21 import org.jacoco.core.data.IExecutionDataVisitor;
     22 import org.jacoco.core.data.ISessionInfoVisitor;
     23 import org.jacoco.core.data.SessionInfo;
     24 
     25 class TestStorage implements IExecutionDataVisitor, ISessionInfoVisitor {
     26 
     27 	private final Map<Long, ExecutionData> data = new HashMap<Long, ExecutionData>();
     28 
     29 	private SessionInfo info;
     30 
     31 	public void assertSize(int size) {
     32 		assertEquals(size, data.size(), 0.0);
     33 	}
     34 
     35 	public ExecutionData getData(long classId) {
     36 		return data.get(Long.valueOf(classId));
     37 	}
     38 
     39 	public SessionInfo getSessionInfo() {
     40 		return info;
     41 	}
     42 
     43 	public void assertData(long classId, boolean[] expected) {
     44 		assertSame(expected, getData(classId).getProbes());
     45 	}
     46 
     47 	// === ICoverageDataVisitor ===
     48 
     49 	public void visitClassExecution(final ExecutionData ed) {
     50 		data.put(Long.valueOf(ed.getId()), ed);
     51 	}
     52 
     53 	// === ISessionInfoVisitor ===
     54 
     55 	public void visitSessionInfo(SessionInfo info) {
     56 		this.info = info;
     57 	}
     58 
     59 }