Commit | Line | Data |
---|---|---|
73005152 | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2011, 2014 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 | |
2bdf0193 | 14 | package org.eclipse.tracecompass.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 | |
aa353506 | 20 | import org.eclipse.jdt.annotation.NonNull; |
2bdf0193 AM |
21 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
22 | import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; | |
2bdf0193 AM |
23 | import org.eclipse.tracecompass.tmf.core.event.TmfEvent; |
24 | import org.eclipse.tracecompass.tmf.core.event.TmfEventField; | |
25 | import org.eclipse.tracecompass.tmf.core.event.TmfEventType; | |
26 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; | |
0c7471fb | 27 | import org.eclipse.tracecompass.tmf.core.trace.ITmfContext; |
2bdf0193 | 28 | import org.eclipse.tracecompass.tmf.core.uml2sd.TmfAsyncSequenceDiagramEvent; |
6e1886bc AM |
29 | import org.junit.Test; |
30 | ||
54a7a54c | 31 | /** |
6e1886bc | 32 | * TmfAsyncSequenceDiagramEventTest |
54a7a54c | 33 | */ |
6e1886bc | 34 | public class TmfAsyncSequenceDiagramEventTest { |
73005152 | 35 | |
aa353506 | 36 | private final @NonNull String fTypeId = "Some type"; |
cbbcc354 | 37 | private final String fLabel0 = "label1"; |
38 | private final String fLabel1 = "label2"; | |
39 | private final String[] fLabels = new String[] { fLabel0, fLabel1 }; | |
73005152 | 40 | |
065cc19b AM |
41 | private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2); |
42 | private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2); | |
e600c338 | 43 | private final TmfEventType fType = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels)); |
73005152 | 44 | |
2771b032 AM |
45 | private final ITmfEvent fEvent1; |
46 | private final ITmfEvent fEvent2; | |
4c564a2d FC |
47 | private final TmfEventField fContent1; |
48 | private final TmfEventField fContent2; | |
73005152 | 49 | |
6e1886bc AM |
50 | /** |
51 | * Constructor for the test case | |
52 | */ | |
73005152 | 53 | public TmfAsyncSequenceDiagramEventTest() { |
214cc822 | 54 | fContent1 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some content", null); |
e1de2fd4 | 55 | fEvent1 = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, fTimestamp1, fType, fContent1); |
73005152 | 56 | |
214cc822 | 57 | fContent2 = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, "Some other content", null); |
e1de2fd4 | 58 | fEvent2 = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, fTimestamp2, fType, fContent2); |
73005152 | 59 | } |
9b749023 | 60 | |
6e1886bc AM |
61 | /** |
62 | * Main test | |
63 | */ | |
64 | @Test | |
73005152 BH |
65 | public void testTmfAsyncSequenceDiagramEvent() { |
66 | TmfAsyncSequenceDiagramEvent event = null; | |
9b749023 AM |
67 | |
68 | // Check for illegal arguments (i.e. null for the parameters) | |
73005152 BH |
69 | try { |
70 | event = new TmfAsyncSequenceDiagramEvent(null, null, null, null, null); | |
71 | fail(); | |
72 | } catch (IllegalArgumentException e) { | |
73 | // success | |
74 | assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("startEvent=null")); | |
75 | } | |
9b749023 | 76 | |
73005152 BH |
77 | try { |
78 | event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, null, null, null); | |
79 | fail(); | |
80 | } catch (IllegalArgumentException e) { | |
81 | // success | |
82 | assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("sender=null")); | |
83 | } | |
9b749023 | 84 | |
73005152 BH |
85 | try { |
86 | event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, null, null, null); | |
87 | fail(); | |
88 | } catch (IllegalArgumentException e) { | |
89 | // success | |
90 | assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("receiver=null")); | |
91 | } | |
92 | ||
93 | try { | |
94 | event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, "sender", null, null); | |
95 | fail(); | |
96 | } catch (IllegalArgumentException e) { | |
97 | // success | |
98 | assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("name=null")); | |
99 | } | |
9b749023 | 100 | |
73005152 BH |
101 | try { |
102 | event = new TmfAsyncSequenceDiagramEvent(fEvent1, null, "sender", "receiver", "signal"); | |
103 | fail(); | |
104 | } catch (IllegalArgumentException e) { | |
105 | // success | |
106 | assertTrue("TmfAsyncSequenceDiagramEvent", e.getMessage().contains("endEvent=null")); | |
107 | } | |
108 | ||
109 | try { | |
110 | event = new TmfAsyncSequenceDiagramEvent(fEvent1, fEvent2, "sender", "receiver", "signal"); | |
111 | // success | |
065cc19b AM |
112 | assertEquals("testTmfAsyncSequenceDiagramEvent", 0, event.getStartTime().compareTo(fTimestamp1)); |
113 | assertEquals("testTmfAsyncSequenceDiagramEvent", 0, event.getEndTime().compareTo(fTimestamp2)); | |
73005152 BH |
114 | assertEquals("testTmfAsyncSequenceDiagramEvent", "sender", event.getSender()); |
115 | assertEquals("testTmfAsyncSequenceDiagramEvent", "receiver", event.getReceiver()); | |
116 | assertEquals("testTmfAsyncSequenceDiagramEvent", "signal", event.getName()); | |
9b749023 | 117 | |
73005152 BH |
118 | } catch (IllegalArgumentException e) { |
119 | fail(); | |
120 | } | |
121 | } | |
122 | } |