From 1f7ce2e8b261ba5c7ce690b547b27da58c38e890 Mon Sep 17 00:00:00 2001 From: chenlinghy Date: Fri, 11 Sep 2020 14:14:35 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=E4=BF=AE=E6=94=B9service?= =?UTF-8?q?=E5=B1=82=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E6=96=AD=E8=A8=80?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/AreaCodeManagerServiceTest.java | 2 -- .../DisposeAbilityRouterServiceTest.java | 34 ++++++------------- .../DisposeDeviceManagerServiceTest.java | 6 ++-- .../dev/service/DisposeTaskServiceTest.java | 3 ++ 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/test/java/com/dispose/test/dev/service/AreaCodeManagerServiceTest.java b/src/test/java/com/dispose/test/dev/service/AreaCodeManagerServiceTest.java index 7fccfc49..57f921d7 100644 --- a/src/test/java/com/dispose/test/dev/service/AreaCodeManagerServiceTest.java +++ b/src/test/java/com/dispose/test/dev/service/AreaCodeManagerServiceTest.java @@ -32,8 +32,6 @@ public class AreaCodeManagerServiceTest extends InitTestEnvironment { long tolNetflow = areaCodeManagerService.getAreaCodeGroupReserveNetflow(0); log.info("AreaCode {} netflow total: {}", 0, tolNetflow); - - Assert.assertNotNull(tolNetflow); } @Test diff --git a/src/test/java/com/dispose/test/dev/service/DisposeAbilityRouterServiceTest.java b/src/test/java/com/dispose/test/dev/service/DisposeAbilityRouterServiceTest.java index 86d340d1..869fbd56 100644 --- a/src/test/java/com/dispose/test/dev/service/DisposeAbilityRouterServiceTest.java +++ b/src/test/java/com/dispose/test/dev/service/DisposeAbilityRouterServiceTest.java @@ -129,16 +129,13 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfoList)); abilityInfoList.forEach(v -> { - Assert.assertNotNull(v.getDb()); Assert.assertNotNull(v.getDev()); - if (v.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE) { - Assert.assertNull(v.getFirewareInfo()); - Assert.assertFalse(v.isLinkStatus()); - } else { + if (v.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) { + Assert.assertNotNull(v.getDb()); Assert.assertNotNull(v.getFirewareInfo()); - Assert.assertTrue(v.isLinkStatus()); } + Assert.assertTrue(v.isLinkStatus()); }); } @@ -158,16 +155,14 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort()); Assert.assertNotNull(abilityInfo); - Assert.assertNotNull(abilityInfo.getDb()); + Assert.assertNotNull(abilityInfo.getDev()); - if (abilityInfo.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE) { - Assert.assertNull(abilityInfo.getFirewareInfo()); - Assert.assertFalse(abilityInfo.isLinkStatus()); - } else { + if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) { + Assert.assertNotNull(abilityInfo.getDb()); Assert.assertNotNull(abilityInfo.getFirewareInfo()); - Assert.assertTrue(abilityInfo.isLinkStatus()); } + Assert.assertTrue(abilityInfo.isLinkStatus()); abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getId()); @@ -175,13 +170,10 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { Assert.assertNotNull(abilityInfo.getDb()); Assert.assertNotNull(abilityInfo.getDev()); - if (abilityInfo.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE) { - Assert.assertNull(abilityInfo.getFirewareInfo()); - Assert.assertFalse(abilityInfo.isLinkStatus()); - } else { + if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) { Assert.assertNotNull(abilityInfo.getFirewareInfo()); - Assert.assertTrue(abilityInfo.isLinkStatus()); } + Assert.assertTrue(abilityInfo.isLinkStatus()); }); } @@ -267,16 +259,12 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment { AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort()); Assert.assertNotNull(abilityInfo); - Assert.assertNotNull(abilityInfo.getDb()); Assert.assertNotNull(abilityInfo.getDev()); - if (abilityInfo.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE) { - Assert.assertNull(abilityInfo.getFirewareInfo()); - Assert.assertFalse(abilityInfo.isLinkStatus()); - } else { + if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) { Assert.assertNotNull(abilityInfo.getFirewareInfo()); - Assert.assertTrue(abilityInfo.isLinkStatus()); } + Assert.assertTrue(abilityInfo.isLinkStatus()); }); } diff --git a/src/test/java/com/dispose/test/dev/service/DisposeDeviceManagerServiceTest.java b/src/test/java/com/dispose/test/dev/service/DisposeDeviceManagerServiceTest.java index 045fa87e..0a1a3f9d 100644 --- a/src/test/java/com/dispose/test/dev/service/DisposeDeviceManagerServiceTest.java +++ b/src/test/java/com/dispose/test/dev/service/DisposeDeviceManagerServiceTest.java @@ -21,6 +21,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; @@ -39,6 +40,7 @@ import java.util.List; @SpringBootTest @Slf4j @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @Transactional @Rollback public class DisposeDeviceManagerServiceTest extends InitTestEnvironment { @@ -118,12 +120,12 @@ public class DisposeDeviceManagerServiceTest extends InitTestEnvironment { if (v.getFirstParam() == ErrorCode.ERR_OK) { Assert.assertNotNull(v.getSecondParam()); Assert.assertNotNull(v.getSecondParam().getId()); - } else if (v.getFirstParam() == ErrorCode.ERR_DEVICEEXISTS) { + } else if(v.getFirstParam() == ErrorCode.ERR_DEVICEEXISTS) { Assert.assertNotNull(v.getSecondParam()); Assert.assertNotNull(v.getSecondParam().getId()); Assert.assertEquals(v.getSecondParam().getStatus(), ObjectStatus.NORMAL); } else { - Assert.assertNull(v.getSecondParam()); + Assert.assertNotNull(v.getSecondParam()); } }); } diff --git a/src/test/java/com/dispose/test/dev/service/DisposeTaskServiceTest.java b/src/test/java/com/dispose/test/dev/service/DisposeTaskServiceTest.java index 4b73b93a..f065451d 100644 --- a/src/test/java/com/dispose/test/dev/service/DisposeTaskServiceTest.java +++ b/src/test/java/com/dispose/test/dev/service/DisposeTaskServiceTest.java @@ -23,6 +23,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; @@ -39,6 +40,7 @@ import java.security.NoSuchAlgorithmException; @SpringBootTest @Slf4j @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @Transactional @Rollback public class DisposeTaskServiceTest extends InitTestEnvironment { @@ -113,6 +115,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment { } else { Assert.assertNotEquals(ret.getFirstParam().getCode(), ErrorCode.ERR_OK.getCode()); } + Assert.assertEquals(ret.getSecondParam().getId(), disposeTaskManager.getDisposeTask(newTask.getDeviceId(), newTask.getDisposeIp(), newTask.getDisposeCapacity()).getId());