Skip to content

Commit

Permalink
fix: resolve PMD Checks, unnecessary imports, unused package.
Browse files Browse the repository at this point in the history
  • Loading branch information
JAYDIPSINH27 committed Mar 20, 2024
1 parent b2b0243 commit 3659ba8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 36 deletions.
7 changes: 1 addition & 6 deletions sofa-boot-project/sofa-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
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.*;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Tests for {@link VerificationResult}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ public void afterRefresh(SofaGenericApplicationContext context, Throwable throwa
failed = throwable != null;
}



public boolean isStarted() {
return started;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
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.*;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* Tests for {@link StartupReporter}.
Expand All @@ -24,12 +22,13 @@ public class StartupReporterTests {
ConfigurableApplicationContext mockContext;

@Mock
ConfigurableEnvironment mockEnvironment;
ConfigurableEnvironment mockEnvironment;

@BeforeEach
public void setup() {
MockitoAnnotations.openMocks(this);
}

@Test
public void testApplicationBootFinish() {
StartupReporter startupReporter = new StartupReporter();
Expand All @@ -45,13 +44,10 @@ public void testAddCommonStartupStat() {
});
}


@Test
public void testDrainStartupStaticsModel() {
StartupReporter startupReporter = new StartupReporter();
assertNotNull(startupReporter.drainStartupStaticsModel());
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@
package com.alipay.sofa.boot.util;

import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.cloud.util.PropertyUtils;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

/**
* Tests for {@link SofaBootEnvUtils}.
Expand Down Expand Up @@ -73,16 +68,16 @@ public void testInitSpringTestEnv() {
}

private boolean isInitSpringTestEnv() {
StackTraceElement[] stackTrace = new StackTraceElement[]{
StackTraceElement[] stackTrace = new StackTraceElement[] {
new StackTraceElement("SomeClass", "someMethod", "SomeClass.java", 10),
new StackTraceElement("AnotherClass", "loadContext", "AnotherClass.java", 20),
new StackTraceElement("org.springframework.boot.test.context.SpringBootContextLoader",
"loadContext", "SpringBootContextLoader.java", 30)
};
new StackTraceElement(
"org.springframework.boot.test.context.SpringBootContextLoader", "loadContext",
"SpringBootContextLoader.java", 30) };
boolean TEST_ENV = false;
for (StackTraceElement stackTraceElement : stackTrace) {
if ("loadContext".equals(stackTraceElement.getMethodName())
&& "org.springframework.boot.test.context.SpringBootContextLoader"
&& "org.springframework.boot.test.context.SpringBootContextLoader"
.equals(stackTraceElement.getClassName())) {
TEST_ENV = true;
break;
Expand All @@ -91,8 +86,3 @@ private boolean isInitSpringTestEnv() {
return TEST_ENV;
}
}





0 comments on commit 3659ba8

Please sign in to comment.