-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test: add new test cases. #1299
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e22cd08
Add test for Startup Reporter, SofaBootEnvUtils, SofaGenericApplicati…
JAYDIPSINH27 6ae9c91
Add test for VerificationResult Class
JAYDIPSINH27 1b81614
add test for Env utils
JAYDIPSINH27 4299dd9
Add Comments
JAYDIPSINH27 1bd24f4
Merge pull request #1 from JAYDIPSINH27/test/new_test
JAYDIPSINH27 1790b70
Merge branch 'sofastack:master' into master
JAYDIPSINH27 b2b0243
Merge branch 'sofastack:master' into master
JAYDIPSINH27 3659ba8
fix: resolve PMD Checks, unnecessary imports, unused package.
JAYDIPSINH27 6f26c8e
cleanup: add comments.
JAYDIPSINH27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...t/sofa-boot/src/test/java/com/alipay/sofa/boot/compatibility/VerificationResultTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.alipay.sofa.boot.compatibility; | ||
|
||
import com.alipay.sofa.boot.compatibility.VerificationResult; | ||
import com.alipay.sofa.boot.util.SofaBootEnvUtils; | ||
import org.junit.jupiter.api.Test; | ||
import static org.assertj.core.api.Assertions.*; | ||
|
||
/** | ||
* Tests for {@link VerificationResult}. | ||
* | ||
* @author JPSINH27 | ||
* @version VerificationResultTests, v 0.1 2024年03月02日 10:20 PM | ||
*/ | ||
public class VerificationResultTests { | ||
|
||
@Test | ||
public void testEquals_SameDescriptionAndAction_ReturnsTrue() { | ||
VerificationResult result1 = VerificationResult.notCompatible("Error", "Take action"); | ||
VerificationResult result2 = VerificationResult.notCompatible("Error", "Take action"); | ||
assertThat(result1).isEqualTo(result2); | ||
} | ||
|
||
@Test | ||
public void testEquals_DifferentDescriptions_ReturnsFalse() { | ||
VerificationResult result1 = VerificationResult.notCompatible("Error 1", "Take action"); | ||
VerificationResult result2 = VerificationResult.notCompatible("Error 2", "Take action"); | ||
assertThat(result1).isNotEqualTo(result2); | ||
} | ||
|
||
@Test | ||
public void testEquals_DifferentActions_ReturnsFalse() { | ||
VerificationResult result1 = VerificationResult.notCompatible("Error", "Take action 1"); | ||
VerificationResult result2 = VerificationResult.notCompatible("Error", "Take action 2"); | ||
assertThat(result1).isNotEqualTo(result2); | ||
} | ||
|
||
@Test | ||
public void testEquals_ComparingWithNull_ReturnsFalse() { | ||
VerificationResult result1 = VerificationResult.notCompatible("Error", "Take action"); | ||
assertThat(result1).isNotEqualTo(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ot-project/sofa-boot/src/test/java/com/alipay/sofa/boot/startup/StartupReporterTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.alipay.sofa.boot.startup; | ||
|
||
import com.alipay.sofa.boot.env.SofaBootEnvironmentPostProcessor; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
import org.springframework.core.env.ConfigurableEnvironment; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
/** | ||
* Tests for {@link StartupReporter}. | ||
* | ||
* @author JPSINH27 | ||
* @version StartupReporterTests.java, v 0.1 2024年01月03日 10:19 PM | ||
*/ | ||
public class StartupReporterTests { | ||
|
||
@Mock | ||
ConfigurableApplicationContext mockContext; | ||
|
||
@Mock | ||
ConfigurableEnvironment mockEnvironment; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
@Test | ||
public void testApplicationBootFinish() { | ||
StartupReporter startupReporter = new StartupReporter(); | ||
assertDoesNotThrow(startupReporter::applicationBootFinish); | ||
} | ||
|
||
@Test | ||
public void testAddCommonStartupStat() { | ||
StartupReporter startupReporter = new StartupReporter(); | ||
BaseStat baseStat = new BaseStat(); | ||
assertDoesNotThrow(() -> { | ||
startupReporter.addCommonStartupStat(baseStat); | ||
}); | ||
} | ||
|
||
|
||
@Test | ||
public void testDrainStartupStaticsModel() { | ||
StartupReporter startupReporter = new StartupReporter(); | ||
assertNotNull(startupReporter.drainStartupStaticsModel()); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add this dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ci run fail, please check it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please run “mvn compile” to update code format before you submit pr