-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.solace.maas.ep.common.model; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class SempEntityTypeTest { | ||
|
||
@Test | ||
void testFromValue() { | ||
SempEntityType entityType = SempEntityType.fromValue("solaceQueue"); | ||
assert entityType == SempEntityType.solaceQueue; | ||
} | ||
|
||
@Test | ||
void testGetValue() { | ||
SempEntityType entityType = SempEntityType.solaceQueue; | ||
assert entityType.getValue().equals("solaceQueue"); | ||
} | ||
|
||
@Test | ||
void testUnsupportedEntityType() { | ||
try { | ||
SempEntityType entityType = SempEntityType.fromValue("unsupported"); | ||
} catch (IllegalArgumentException e) { | ||
assert e.getMessage().equals("Unsupported entity type: unsupported"); | ||
} | ||
} | ||
|
||
@Test | ||
void testFromValueNull() { | ||
try { | ||
SempEntityType entityType = SempEntityType.fromValue(null); | ||
} catch (IllegalArgumentException e) { | ||
assert e.getMessage().equals("Unsupported entity type: null"); | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.solace.maas.ep.event.management.agent.subscriber; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
public class EmRestartSimulatingPersistentMessageHandlerObserverTest { | ||
|
||
@Test | ||
void testOnPhaseChangeRestartSimulated() { | ||
EmaRestartSimulatingPersistentMessageHandlerObserver emaRestartSimulatingPersistentMessageHandlerObserver = new EmaRestartSimulatingPersistentMessageHandlerObserver(); | ||
Check failure on line 11 in service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/EmRestartSimulatingPersistentMessageHandlerObserverTest.java GitHub Actions / Checkstylecom.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck
|
||
emaRestartSimulatingPersistentMessageHandlerObserver.setRestartSimulated(true); | ||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.PRE_PROCESSOR_EXECUTION)).isFalse(); | ||
Check failure on line 13 in service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/EmRestartSimulatingPersistentMessageHandlerObserverTest.java GitHub Actions / Checkstylecom.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck
|
||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.PRE_ACKNOWLEDGED)).isFalse(); | ||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.ACKNOWLEDGED)).isTrue(); | ||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.FAILED)).isTrue(); | ||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.PROCESSOR_COMPLETED)).isTrue(); | ||
Check failure on line 17 in service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/EmRestartSimulatingPersistentMessageHandlerObserverTest.java GitHub Actions / Checkstylecom.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck
|
||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.PROCESSING_INITIATED)).isTrue(); | ||
Check failure on line 18 in service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/EmRestartSimulatingPersistentMessageHandlerObserverTest.java GitHub Actions / Checkstylecom.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck
|
||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.RECEIVED)).isTrue(); | ||
} | ||
|
||
@Test | ||
void testOnPhaseChangeRestartNotSimulated() { | ||
EmaRestartSimulatingPersistentMessageHandlerObserver emaRestartSimulatingPersistentMessageHandlerObserver = new EmaRestartSimulatingPersistentMessageHandlerObserver(); | ||
Check failure on line 24 in service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/EmRestartSimulatingPersistentMessageHandlerObserverTest.java GitHub Actions / Checkstylecom.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck
|
||
emaRestartSimulatingPersistentMessageHandlerObserver.setRestartSimulated(false); | ||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.PRE_PROCESSOR_EXECUTION)).isTrue(); | ||
Check failure on line 26 in service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/EmRestartSimulatingPersistentMessageHandlerObserverTest.java GitHub Actions / Checkstylecom.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck
|
||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.PRE_ACKNOWLEDGED)).isTrue(); | ||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.ACKNOWLEDGED)).isTrue(); | ||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.FAILED)).isTrue(); | ||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.PROCESSOR_COMPLETED)).isTrue(); | ||
Check failure on line 30 in service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/EmRestartSimulatingPersistentMessageHandlerObserverTest.java GitHub Actions / Checkstylecom.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck
|
||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.PROCESSING_INITIATED)).isTrue(); | ||
Check failure on line 31 in service/application/src/test/java/com/solace/maas/ep/event/management/agent/subscriber/EmRestartSimulatingPersistentMessageHandlerObserverTest.java GitHub Actions / Checkstylecom.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck
|
||
assertThat(emaRestartSimulatingPersistentMessageHandlerObserver.onPhaseChange(null, PersistentMessageHandlerObserverPhase.RECEIVED)).isTrue(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.solace.maas.ep.event.management.agent.plugin.terraform; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.solace.maas.ep.event.management.agent.plugin.command.model.CommandResult; | ||
import com.solace.maas.ep.event.management.agent.plugin.command.model.JobStatus; | ||
import com.solace.maas.ep.event.management.agent.plugin.terraform.manager.TerraformLogProcessingService; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
|
||
|
||
public class TerraformLogProcessingServiceTest { | ||
|
||
|
||
@Test | ||
void testBuildTfStateFileDeletionFailureResult(){ | ||
RuntimeException rootCause = new RuntimeException("rootCause"); | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
TerraformLogProcessingService terraformLogProcessingService = new TerraformLogProcessingService(objectMapper); | ||
CommandResult result = terraformLogProcessingService.buildTfStateFileDeletionFailureResult(rootCause); | ||
assertThat(result.getStatus()).isEqualTo(JobStatus.error); | ||
assertThat(result.getLogs().size()).isEqualTo(1); | ||
Map<String, Object> log = result.getLogs().get(0); | ||
assertThat(log.get("message")).isEqualTo("Failed removing Terraform state: rootCause"); | ||
assertThat(log.get("level")).isEqualTo("ERROR"); | ||
assertThat(log.get("timestamp")).isNotNull(); | ||
} | ||
} |