|
1 | 1 | /*
|
2 |
| - * Copyright 2015-2022 the original author or authors. |
| 2 | + * Copyright 2015-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.cloud.dataflow.shell.command;
|
18 | 18 |
|
| 19 | +import java.io.File; |
19 | 20 | import java.util.Arrays;
|
20 | 21 |
|
21 | 22 | import org.junit.jupiter.api.AfterEach;
|
|
38 | 39 | import org.springframework.shell.table.Table;
|
39 | 40 |
|
40 | 41 | import static org.assertj.core.api.Assertions.assertThat;
|
| 42 | +import static org.assertj.core.api.Assertions.in; |
41 | 43 | import static org.junit.Assert.assertEquals;
|
42 | 44 | import static org.mockito.Mockito.mock;
|
43 | 45 | import static org.mockito.Mockito.when;
|
@@ -67,20 +69,48 @@ public void destroyStreams() {
|
67 | 69 |
|
68 | 70 | @Test
|
69 | 71 | public void testStreamLifecycleForTickTock() throws InterruptedException {
|
70 |
| - logger.info("Starting Stream Test for TickTock"); |
71 |
| - Thread.sleep(2000); |
72 | 72 | String streamName = generateUniqueStreamOrTaskName();
|
73 |
| - Info info = new Info(); |
74 |
| - Status status = new Status(); |
75 |
| - status.setStatusCode(StatusCode.UNKNOWN); |
76 |
| - status.setPlatformStatus(null); |
77 |
| - info.setStatus(status); |
| 73 | + when(skipperClient.status(ArgumentMatchers.anyString())).thenReturn(setupBaseTest()); |
| 74 | + AppDeployer appDeployer = applicationContext.getBean(AppDeployer.class); |
| 75 | + Deployer deployer = new Deployer("testDeployer", "testType", appDeployer, mock(ActuatorOperations.class)); |
| 76 | + when(skipperClient.listDeployers()).thenReturn(Arrays.asList(deployer)); |
| 77 | + stream().create(streamName, "time | log"); |
| 78 | + } |
78 | 79 |
|
79 |
| - when(skipperClient.status(ArgumentMatchers.anyString())).thenReturn(info); |
| 80 | + @Test |
| 81 | + public void testStreamUpdateForTickTock() throws InterruptedException { |
| 82 | + String streamName = generateUniqueStreamOrTaskName(); |
| 83 | + |
| 84 | + when(skipperClient.status(ArgumentMatchers.anyString())).thenReturn(setupBaseTest()); |
| 85 | + AppDeployer appDeployer = applicationContext.getBean(AppDeployer.class); |
| 86 | + Deployer deployer = new Deployer("testDeployer", "testType", appDeployer, mock(ActuatorOperations.class)); |
| 87 | + when(skipperClient.listDeployers()).thenReturn(Arrays.asList(deployer)); |
| 88 | + stream().create(streamName, "time | log"); |
| 89 | + stream().update(streamName, "version.log=3.2.1","Update request has been sent for the stream"); |
| 90 | + } |
| 91 | + |
| 92 | + @Test |
| 93 | + public void testStreamUpdatePropFileForTickTock() throws InterruptedException { |
| 94 | + String streamName = generateUniqueStreamOrTaskName(); |
| 95 | + |
| 96 | + when(skipperClient.status(ArgumentMatchers.anyString())).thenReturn(setupBaseTest()); |
80 | 97 | AppDeployer appDeployer = applicationContext.getBean(AppDeployer.class);
|
81 | 98 | Deployer deployer = new Deployer("testDeployer", "testType", appDeployer, mock(ActuatorOperations.class));
|
82 | 99 | when(skipperClient.listDeployers()).thenReturn(Arrays.asList(deployer));
|
83 | 100 | stream().create(streamName, "time | log");
|
| 101 | + File resourcesDirectory = new File("src/test/resources"); |
| 102 | + stream().updateFile(streamName, resourcesDirectory.getAbsolutePath() + "/myproperties.properties","Update request has been sent for the stream"); |
| 103 | + } |
| 104 | + |
| 105 | + private Info setupBaseTest() throws InterruptedException { |
| 106 | + logger.info("Starting Stream Test for TickTock Update"); |
| 107 | + Thread.sleep(2000); |
| 108 | + Info info = new Info(); |
| 109 | + Status status = new Status(); |
| 110 | + status.setStatusCode(StatusCode.UNKNOWN); |
| 111 | + status.setPlatformStatus(null); |
| 112 | + info.setStatus(status); |
| 113 | + return info; |
84 | 114 | }
|
85 | 115 |
|
86 | 116 | @Test
|
|
0 commit comments