Skip to content

Commit c743c42

Browse files
#1110: Fixed ide status fails with IllegalStateException when being offline (#1125)
Co-authored-by: Jörg Hohwiller <[email protected]>
1 parent 8a9936e commit c743c42

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

cli/awstest

-1
This file was deleted.

cli/src/main/java/com/devonfw/tools/ide/commandlet/StatusCommandlet.java

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ public void run() {
4343
logSettingsLegacyStatus();
4444
logMigrationStatus();
4545
}
46+
checkForUpdate();
47+
}
48+
49+
private void checkForUpdate() {
50+
if (!this.context.isOnline()) {
51+
this.context.warning("Check for newer version of IDEasy is skipped due to no network connectivity.");
52+
return;
53+
}
4654
new IdeasyCommandlet(this.context, null).checkIfUpdateIsAvailable();
4755
logSystemInfo();
4856
}

cli/src/test/java/com/devonfw/tools/ide/commandlet/StatusCommandletTest.java

+20-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.junit.jupiter.api.Test;
44

5-
import com.devonfw.tools.ide.cli.CliArguments;
65
import com.devonfw.tools.ide.context.AbstractIdeContextTest;
76
import com.devonfw.tools.ide.context.IdeTestContext;
87

@@ -17,13 +16,30 @@ public class StatusCommandletTest extends AbstractIdeContextTest {
1716
public void testStatusOutsideOfHome() {
1817
//arrange
1918
IdeTestContext context = new IdeTestContext();
20-
CliArguments args = new CliArguments("status");
21-
args.next();
19+
StatusCommandlet status = context.getCommandletManager().getCommandlet(StatusCommandlet.class);
2220

2321
//act
24-
context.run(args);
22+
status.run();
2523

2624
//assert
2725
assertThat(context).logAtWarning().hasMessageContaining("You are not inside an IDE project: ");
2826
}
27+
28+
/**
29+
* Tests the output if {@link StatusCommandlet} is run without internet connection.
30+
*/
31+
@Test
32+
public void testStatusWhenOffline() {
33+
34+
// arrange
35+
IdeTestContext context = new IdeTestContext();
36+
context.setOnline(false);
37+
StatusCommandlet status = context.getCommandletManager().getCommandlet(StatusCommandlet.class);
38+
39+
// act
40+
status.run();
41+
42+
// assert
43+
assertThat(context).logAtWarning().hasMessage("Check for newer version of IDEasy is skipped due to no network connectivity.");
44+
}
2945
}

0 commit comments

Comments
 (0)