Commit | Line | Data |
---|---|---|
73005152 | 1 | /******************************************************************************* |
6e1886bc | 2 | * Copyright (c) 2011, 2013 Ericsson |
9b749023 | 3 | * |
73005152 BH |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
9b749023 | 8 | * |
73005152 BH |
9 | * Contributors: |
10 | * Bernd Hufmann - Initial API and implementation | |
6e1886bc | 11 | * Alexandre Montplaisir - Port to JUnit4 |
73005152 | 12 | *******************************************************************************/ |
6e1886bc | 13 | |
6c13869b | 14 | package org.eclipse.linuxtools.tmf.core.tests.uml2sd; |
73005152 | 15 | |
6e1886bc AM |
16 | import static org.junit.Assert.assertEquals; |
17 | import static org.junit.Assert.assertTrue; | |
18 | import static org.junit.Assert.fail; | |
73005152 | 19 | |
2771b032 | 20 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
4c564a2d | 21 | import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; |
9b749023 | 22 | import org.eclipse.linuxtools.tmf.core.event.ITmfEventType; |
6c13869b | 23 | import org.eclipse.linuxtools.tmf.core.event.TmfEvent; |
4c564a2d | 24 | import org.eclipse.linuxtools.tmf.core.event.TmfEventField; |
6c13869b | 25 | import org.eclipse.linuxtools.tmf.core.event.TmfEventType; |
3bd46eef | 26 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp; |
6c13869b | 27 | import org.eclipse.linuxtools.tmf.core.uml2sd.TmfSyncSequenceDiagramEvent; |
73005152 | 28 | |
6e1886bc AM |
29 | import org.junit.Test; |
30 | ||
54a7a54c | 31 | /** |
6e1886bc | 32 | * TmfSyncSequenceDiagramEventTest |
54a7a54c | 33 | */ |
6e1886bc | 34 | public class TmfSyncSequenceDiagramEventTest { |
73005152 | 35 | |
9b749023 | 36 | private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID; |
cbbcc354 | 37 | private final String fTypeId = "Some type"; |
38 | private final String fLabel0 = "label1"; | |
39 | private final String fLabel1 = "label2"; | |
40 | private final String[] fLabels = new String[] { fLabel0, fLabel1 }; | |
73005152 | 41 | |
4641c2f7 FC |
42 | private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5); |
43 | private final String fSource = "Source"; | |
4c564a2d | 44 | private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels)); |
4641c2f7 | 45 | private final String fReference = "Some reference"; |
73005152 | 46 | |
2771b032 | 47 | private final ITmfEvent fEvent1; |
4c564a2d | 48 | private final TmfEventField fContent1; |
73005152 | 49 | |
6e1886bc AM |
50 | /** |
51 | * Constructor for the test case | |
52 | */ | |
53 | public TmfSyncSequenceDiagramEventTest() { | |
214cc822 | 54 | fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content", null); |
4c564a2d | 55 | fEvent1 = new TmfEvent(null, fTimestamp1, fSource, fType, fContent1, fReference); |
73005152 BH |
56 | } |
57 | ||
6e1886bc AM |
58 | /** |
59 | * Main test | |
60 | */ | |
61 | @Test | |
73005152 BH |
62 | public void testTmfSyncSequenceDiagramEvent() { |
63 | TmfSyncSequenceDiagramEvent event = null; | |
64 | try { | |
65 | event = new TmfSyncSequenceDiagramEvent(null, null, null, null); | |
66 | fail(); | |
67 | } catch (IllegalArgumentException e) { | |
68 | // success | |
69 | assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("startEvent=null")); | |
70 | } | |
9b749023 | 71 | |
73005152 BH |
72 | try { |
73 | event = new TmfSyncSequenceDiagramEvent(fEvent1, null, null, null); | |
74 | fail(); | |
75 | } catch (IllegalArgumentException e) { | |
76 | // success | |
77 | assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("sender=null")); | |
78 | } | |
9b749023 | 79 | |
73005152 BH |
80 | try { |
81 | event = new TmfSyncSequenceDiagramEvent(fEvent1, "sender", null, null); | |
82 | fail(); | |
83 | } catch (IllegalArgumentException e) { | |
84 | // success | |
85 | assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("receiver=null")); | |
86 | } | |
87 | ||
88 | try { | |
89 | event = new TmfSyncSequenceDiagramEvent(fEvent1, "sender", "receiver", null); | |
90 | fail(); | |
91 | } catch (IllegalArgumentException e) { | |
92 | // success | |
93 | assertTrue("testTmfSyncSequenceDiagramEvent", e.getMessage().contains("name=null")); | |
94 | } | |
9b749023 | 95 | |
73005152 BH |
96 | try { |
97 | event = new TmfSyncSequenceDiagramEvent(fEvent1, "sender", "receiver", "signal"); | |
98 | // success | |
99 | assertEquals("testTmfSyncSequenceDiagramEvent", 0, event.getStartTime().compareTo(fTimestamp1, true)); | |
100 | assertEquals("testTmfSyncSequenceDiagramEvent", "sender", event.getSender()); | |
101 | assertEquals("testTmfSyncSequenceDiagramEvent", "receiver", event.getReceiver()); | |
102 | assertEquals("testTmfSyncSequenceDiagramEvent", "signal", event.getName()); | |
9b749023 | 103 | |
73005152 BH |
104 | } catch (IllegalArgumentException e) { |
105 | fail(); | |
106 | } | |
107 | } | |
108 | } |