Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'java'
id 'application'
id 'jacoco'
id 'org.sonarqube' version '6.0.1.5171'
}

Expand Down Expand Up @@ -76,6 +77,17 @@ tasks.register('fatJar', Jar) {
with jar
}

tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}

tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
reports {
xml.required.set(true)
}
}

// SonarQube configuration
sonar {
properties {
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/org/openmbee/flexo/cli/commands/InitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,16 @@ private void waitForServices() throws Exception {
// Wait for Fuseki (port 3030) and MMS (port 8080) to be available
int maxAttempts = 30;
int attempt = 0;

while (attempt < maxAttempts) {
try {
// Check Fuseki
java.net.Socket fusekiSocket = new java.net.Socket();
fusekiSocket.connect(new java.net.InetSocketAddress("localhost", 3030), 1000);
fusekiSocket.close();

// Check MMS
java.net.Socket mmsSocket = new java.net.Socket();
mmsSocket.connect(new java.net.InetSocketAddress("localhost", 8080), 1000);
mmsSocket.close();
try (java.net.Socket fusekiSocket = new java.net.Socket()) {
fusekiSocket.connect(new java.net.InetSocketAddress("localhost", 3030), 1000);
}

try (java.net.Socket mmsSocket = new java.net.Socket()) {
mmsSocket.connect(new java.net.InetSocketAddress("localhost", 8080), 1000);
}

// Both services are up
ConsoleUtil.success(" Services are ready");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void testGetBranchSuccess() throws Exception {

FlexoMmsClient client = createClientWithMockedHttp();

Branch branch = client.getBranch("org1", "repo1", "develop");
client.getBranch("org1", "repo1", "develop");

// Branch might be null if parsing returns empty list
// The test verifies the method completes without exception
Expand Down Expand Up @@ -155,7 +155,7 @@ void testCreateBranchSuccess() throws Exception {

FlexoMmsClient client = createClientWithMockedHttp();

Branch branch = client.createBranch("org1", "repo1", "feature", null);
client.createBranch("org1", "repo1", "feature", null);

// Verify PUT was executed twice (create + get)
verify(mockHttpClient, atLeastOnce()).execute(any(HttpUriRequestBase.class));
Expand Down
20 changes: 16 additions & 4 deletions src/test/java/org/openmbee/flexo/cli/config/FlexoConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,29 @@

class FlexoConfigTest {

private Map<String, String> originalEnv;
/*
* These lifecycle methods are intentionally empty because:
* - System.getenv() cannot be modified or reset in Java, so storing the original
* environment doesn't help with isolation between tests
* - FlexoConfig instances are independent and don't share mutable state
* - Each test creates fresh FlexoConfig instances that load from defaults/files
* - Test isolation is achieved through fresh config objects per test, not through
* environment restoration which is not possible in Java
*/

@BeforeEach
void setUp() {
// Store original environment variables
originalEnv = new HashMap<>(System.getenv());
// Lifecycle methods are intentionally empty.
// System.getenv() cannot be modified or reset in Java, so storing the original
// environment doesn't help with isolation between tests. Each test creates fresh
// FlexoConfig instances that load from defaults/files independently.
}

@AfterEach
void tearDown() {
// Note: Cannot fully restore environment in Java, but tests are isolated
// Lifecycle methods are intentionally empty.
// Test isolation is achieved through fresh FlexoConfig objects per test,
// not through environment restoration which is not possible in Java.
}

@Test
Expand Down