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.data; 13 14 import static org.junit.Assert.assertEquals; 15 16 import org.junit.Test; 17 18 /** 19 * Unit tests for {@link SessionInfo}. 20 */ 21 public class SessionInfoTest { 22 23 @Test(expected = IllegalArgumentException.class) 24 public void testNullId() { 25 new SessionInfo(null, 1, 2); 26 } 27 28 @Test 29 public void testGetters() { 30 final SessionInfo info = new SessionInfo("id", 1000, 2000); 31 assertEquals("id", info.getId()); 32 assertEquals(1000, info.getStartTimeStamp()); 33 assertEquals(2000, info.getDumpTimeStamp()); 34 } 35 36 @Test 37 public void testCompare() { 38 assertEquals(0, 39 new SessionInfo("id", 1000, 2000).compareTo(new SessionInfo( 40 "id", 1234, 2000))); 41 assertEquals(-1, 42 new SessionInfo("id", 3333, 1999).compareTo(new SessionInfo( 43 "id", 1234, 2000))); 44 assertEquals(+1, 45 new SessionInfo("id", 1234, 2001).compareTo(new SessionInfo( 46 "id", 2222, 2000))); 47 } 48 49 @Test 50 public void testToString() { 51 assertEquals("SessionInfo[id]", 52 new SessionInfo("id", 1000, 2000).toString()); 53 } 54 55 } 56