1+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+ // SPDX-License-Identifier: Apache-2.0
3+
4+ import kotlinx.coroutines.runBlocking
5+ import org.junit.jupiter.api.MethodOrderer
6+ import org.junit.jupiter.api.Order
7+ import org.junit.jupiter.api.Test
8+ import org.junit.jupiter.api.TestInstance
9+ import org.junit.jupiter.api.TestMethodOrder
10+ import com.example.fleetwise.ListSignalCatalogs
11+ import com.example.fleetwise.scenario.createDecoderManifest
12+ import com.example.fleetwise.scenario.createFleet
13+ import com.example.fleetwise.scenario.createModelManifest
14+ import com.example.fleetwise.scenario.createThingIfNotExist
15+ import com.example.fleetwise.scenario.createVehicle
16+ import com.example.fleetwise.scenario.createbranchVehicle
17+ import com.example.fleetwise.scenario.deleteDecoderManifest
18+ import com.example.fleetwise.scenario.deleteFleet
19+ import com.example.fleetwise.scenario.deleteModelManifest
20+ import com.example.fleetwise.scenario.deleteSignalCatalog
21+ import com.example.fleetwise.scenario.deleteVehicle
22+ import com.example.fleetwise.scenario.getVehicleDetails
23+ import com.example.fleetwise.scenario.listSignalCatalogNode
24+ import com.example.fleetwise.scenario.updateDecoderManifest
25+ import com.example.fleetwise.scenario.updateModelManifest
26+ import com.example.fleetwise.scenario.waitForDecoderManifestActive
27+ import com.example.fleetwise.scenario.waitForModelManifestActive
28+ import org.junit.jupiter.api.Assertions.assertTrue
29+
30+ @TestInstance(TestInstance .Lifecycle .PER_CLASS )
31+ @TestMethodOrder(MethodOrderer .OrderAnnotation ::class )
132class FleetwiseTest {
2- }
33+
34+ private val signalCatalogName = " catalogTest10"
35+ private val manifestName = " manifest10"
36+ private val fleetName = " fleet10"
37+ private val vecName = " vehicle10"
38+ private val decName = " decManifest10"
39+ private var signalCatalogArn = " "
40+ private var fleetValue = " "
41+ private var manifestArn = " "
42+ private var decArn = " "
43+
44+ @Test
45+ @Order(1 )
46+ fun testHello () = runBlocking {
47+ runCatching {
48+ ListSignalCatalogs ()
49+ }.onSuccess {
50+ println (" Test 1 Passed Successfully!" )
51+ }.onFailure {
52+ it.printStackTrace()
53+ }.getOrThrow()
54+ }
55+
56+ @Test
57+ @Order(2 )
58+ fun testCat () = runBlocking {
59+ runCatching {
60+ signalCatalogArn = createbranchVehicle(signalCatalogName)
61+ }.onSuccess {
62+ println (" Test 2 Passed Successfully" )
63+ }.onFailure {
64+ it.printStackTrace()
65+ }.getOrThrow()
66+ }
67+
68+ @Test
69+ @Order(3 )
70+ fun testFleet (): Unit = runBlocking {
71+ runCatching {
72+ fleetValue = createFleet(signalCatalogArn, fleetName)
73+ }.onSuccess {
74+ println (" ✅ Test 3 Passed Successfully" )
75+ }.onFailure {
76+ it.printStackTrace()
77+ }.getOrThrow()
78+ }
79+
80+ @Test
81+ @Order(4 )
82+ fun testModelManifest (): Unit = runBlocking {
83+ runCatching {
84+ val nodes = listSignalCatalogNode(signalCatalogName);
85+ manifestArn = nodes?.let { createModelManifest(manifestName, signalCatalogArn, it) }.toString();
86+ }.onSuccess {
87+ println (" ✅ Test 4 Passed Successfully" )
88+ }.onFailure {
89+ it.printStackTrace()
90+ }.getOrThrow()
91+ }
92+
93+ @Test
94+ @Order(5 )
95+ fun testDecodeManifest (): Unit = runBlocking {
96+ runCatching {
97+ decArn = createDecoderManifest(decName, manifestArn)
98+ }.onSuccess {
99+ println (" ✅ Test 5 Passed Successfully" )
100+ }.onFailure {
101+ it.printStackTrace()
102+ }.getOrThrow()
103+ }
104+
105+ @Test
106+ @Order(6 )
107+ fun testManifestStatus (): Unit = runBlocking {
108+ runCatching {
109+ updateModelManifest(manifestName)
110+ waitForModelManifestActive(manifestName)
111+ }.onSuccess {
112+ println (" ✅ Test 6 Passed Successfully" )
113+ }.onFailure {
114+ it.printStackTrace()
115+ }.getOrThrow()
116+ }
117+
118+ @Test
119+ @Order(7 )
120+ fun testDecoderStatus (): Unit = runBlocking {
121+ runCatching {
122+ updateDecoderManifest(decName)
123+ waitForDecoderManifestActive(decName)
124+ }.onSuccess {
125+ println (" ✅ Test 7 Passed Successfully" )
126+ }.onFailure {
127+ it.printStackTrace()
128+ }.getOrThrow()
129+ }
130+
131+ @Test
132+ @Order(8 )
133+ fun testIoTThing (): Unit = runBlocking {
134+ runCatching {
135+ createThingIfNotExist(vecName)
136+ }.onSuccess {
137+ println (" ✅ Test 8 Passed Successfully" )
138+ }.onFailure {
139+ it.printStackTrace()
140+ }.getOrThrow()
141+ }
142+
143+ @Test
144+ @Order(9 )
145+ fun testVehicle (): Unit = runBlocking {
146+ runCatching {
147+ createVehicle(vecName, manifestArn, decArn)
148+ }.onSuccess {
149+ println (" ✅ Test 9 Passed Successfully" )
150+ }.onFailure {
151+ it.printStackTrace()
152+ }.getOrThrow()
153+ }
154+
155+ @Test
156+ @Order(10 )
157+ fun testGetVehicle (): Unit = runBlocking {
158+ runCatching {
159+ getVehicleDetails(vecName)
160+ }.onSuccess {
161+ println (" ✅ Test 10 Passed Successfully" )
162+ }.onFailure {
163+ it.printStackTrace()
164+ }.getOrThrow()
165+ }
166+
167+ @Test
168+ @Order(11 )
169+ fun testDelVehicle () = runBlocking {
170+ runCatching {
171+ deleteVehicle(vecName)
172+ }.onSuccess {
173+ println (" Test 11 Passed Successfully" )
174+ }.onFailure {
175+ it.printStackTrace()
176+ }.getOrThrow()
177+ }
178+
179+ @Test
180+ @Order(12 )
181+ fun testDelDecoder () = runBlocking {
182+ runCatching {
183+ deleteDecoderManifest(decName)
184+ }.onSuccess {
185+ println (" Test 12 Passed Successfully" )
186+ }.onFailure {
187+ it.printStackTrace()
188+ }.getOrThrow()
189+ }
190+
191+ @Test
192+ @Order(13 )
193+ fun testDelMan () = runBlocking {
194+ runCatching {
195+ deleteModelManifest(manifestName)
196+ }.onSuccess {
197+ println (" Test 13 Passed Successfully" )
198+ }.onFailure {
199+ it.printStackTrace()
200+ }.getOrThrow()
201+ }
202+
203+ @Test
204+ @Order(14 )
205+ fun testDelFleet () = runBlocking {
206+ runCatching {
207+ deleteFleet(fleetName)
208+ }.onSuccess {
209+ println (" Test 14 Passed Successfully" )
210+ }.onFailure {
211+ it.printStackTrace()
212+ }.getOrThrow()
213+ }
214+
215+ @Test
216+ @Order(15 )
217+ fun testDelCat () = runBlocking {
218+ runCatching {
219+ deleteSignalCatalog(signalCatalogName)
220+ }.onSuccess {
221+ println (" Test 15 Passed Successfully" )
222+ }.onFailure {
223+ it.printStackTrace()
224+ }.getOrThrow()
225+ }
226+ }
0 commit comments