REM:
1.修改service层单元测试断言问题
This commit is contained in:
chenlinghy 2020-09-11 14:14:35 +08:00
parent 630f5b9968
commit 1f7ce2e8b2
4 changed files with 18 additions and 27 deletions

View File

@ -32,8 +32,6 @@ public class AreaCodeManagerServiceTest extends InitTestEnvironment {
long tolNetflow = areaCodeManagerService.getAreaCodeGroupReserveNetflow(0); long tolNetflow = areaCodeManagerService.getAreaCodeGroupReserveNetflow(0);
log.info("AreaCode {} netflow total: {}", 0, tolNetflow); log.info("AreaCode {} netflow total: {}", 0, tolNetflow);
Assert.assertNotNull(tolNetflow);
} }
@Test @Test

View File

@ -129,16 +129,13 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfoList)); log.info(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(abilityInfoList));
abilityInfoList.forEach(v -> { abilityInfoList.forEach(v -> {
Assert.assertNotNull(v.getDb());
Assert.assertNotNull(v.getDev()); Assert.assertNotNull(v.getDev());
if (v.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE) { if (v.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) {
Assert.assertNull(v.getFirewareInfo()); Assert.assertNotNull(v.getDb());
Assert.assertFalse(v.isLinkStatus());
} else {
Assert.assertNotNull(v.getFirewareInfo()); 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()); AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort());
Assert.assertNotNull(abilityInfo); Assert.assertNotNull(abilityInfo);
Assert.assertNotNull(abilityInfo.getDb());
Assert.assertNotNull(abilityInfo.getDev()); Assert.assertNotNull(abilityInfo.getDev());
if (abilityInfo.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE) { if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) {
Assert.assertNull(abilityInfo.getFirewareInfo()); Assert.assertNotNull(abilityInfo.getDb());
Assert.assertFalse(abilityInfo.isLinkStatus());
} else {
Assert.assertNotNull(abilityInfo.getFirewareInfo()); Assert.assertNotNull(abilityInfo.getFirewareInfo());
Assert.assertTrue(abilityInfo.isLinkStatus());
} }
Assert.assertTrue(abilityInfo.isLinkStatus());
abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getId()); abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getId());
@ -175,13 +170,10 @@ public class DisposeAbilityRouterServiceTest extends InitTestEnvironment {
Assert.assertNotNull(abilityInfo.getDb()); Assert.assertNotNull(abilityInfo.getDb());
Assert.assertNotNull(abilityInfo.getDev()); Assert.assertNotNull(abilityInfo.getDev());
if (abilityInfo.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE) { if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) {
Assert.assertNull(abilityInfo.getFirewareInfo());
Assert.assertFalse(abilityInfo.isLinkStatus());
} else {
Assert.assertNotNull(abilityInfo.getFirewareInfo()); 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()); AbilityInfo abilityInfo = disposeAbilityRouterService.getAbilityDevice(v.getIpAddr(), v.getIpPort());
Assert.assertNotNull(abilityInfo); Assert.assertNotNull(abilityInfo);
Assert.assertNotNull(abilityInfo.getDb());
Assert.assertNotNull(abilityInfo.getDev()); Assert.assertNotNull(abilityInfo.getDev());
if (abilityInfo.getDev().getDeviceType() == DisposeDeviceType.VIRTUAL_DISPOSE) { if (abilityInfo.getDev().getDeviceType() != DisposeDeviceType.VIRTUAL_DISPOSE) {
Assert.assertNull(abilityInfo.getFirewareInfo());
Assert.assertFalse(abilityInfo.isLinkStatus());
} else {
Assert.assertNotNull(abilityInfo.getFirewareInfo()); Assert.assertNotNull(abilityInfo.getFirewareInfo());
Assert.assertTrue(abilityInfo.isLinkStatus());
} }
Assert.assertTrue(abilityInfo.isLinkStatus());
}); });
} }

View File

@ -21,6 +21,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.Rollback; import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -39,6 +40,7 @@ import java.util.List;
@SpringBootTest @SpringBootTest
@Slf4j @Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@Transactional @Transactional
@Rollback @Rollback
public class DisposeDeviceManagerServiceTest extends InitTestEnvironment { public class DisposeDeviceManagerServiceTest extends InitTestEnvironment {
@ -118,12 +120,12 @@ public class DisposeDeviceManagerServiceTest extends InitTestEnvironment {
if (v.getFirstParam() == ErrorCode.ERR_OK) { if (v.getFirstParam() == ErrorCode.ERR_OK) {
Assert.assertNotNull(v.getSecondParam()); Assert.assertNotNull(v.getSecondParam());
Assert.assertNotNull(v.getSecondParam().getId()); 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());
Assert.assertNotNull(v.getSecondParam().getId()); Assert.assertNotNull(v.getSecondParam().getId());
Assert.assertEquals(v.getSecondParam().getStatus(), ObjectStatus.NORMAL); Assert.assertEquals(v.getSecondParam().getStatus(), ObjectStatus.NORMAL);
} else { } else {
Assert.assertNull(v.getSecondParam()); Assert.assertNotNull(v.getSecondParam());
} }
}); });
} }

View File

@ -23,6 +23,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters; import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.Rollback; import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -39,6 +40,7 @@ import java.security.NoSuchAlgorithmException;
@SpringBootTest @SpringBootTest
@Slf4j @Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@Transactional @Transactional
@Rollback @Rollback
public class DisposeTaskServiceTest extends InitTestEnvironment { public class DisposeTaskServiceTest extends InitTestEnvironment {
@ -113,6 +115,7 @@ public class DisposeTaskServiceTest extends InitTestEnvironment {
} else { } else {
Assert.assertNotEquals(ret.getFirstParam().getCode(), ErrorCode.ERR_OK.getCode()); Assert.assertNotEquals(ret.getFirstParam().getCode(), ErrorCode.ERR_OK.getCode());
} }
Assert.assertEquals(ret.getSecondParam().getId(), disposeTaskManager.getDisposeTask(newTask.getDeviceId(), Assert.assertEquals(ret.getSecondParam().getId(), disposeTaskManager.getDisposeTask(newTask.getDeviceId(),
newTask.getDisposeIp(), newTask.getDisposeCapacity()).getId()); newTask.getDisposeIp(), newTask.getDisposeCapacity()).getId());