REM:
1.添加模板选择service层测试。
This commit is contained in:
wangyiyun 2021-01-14 18:01:29 +08:00
parent 6860e9875f
commit 59583d513f
1 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,65 @@
package com.dispose.test.dev.service;
import com.dispose.service.TemplateService;
import com.dispose.test.dev.Global.InitTestEnvironment;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.FixMethodOrder;
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;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
@Transactional
@Rollback
public class TemplateServiceTest extends InitTestEnvironment {
@Resource
private TemplateService templateService;
@Test
public void getTemplateTest() {
Assert.assertEquals("Game_Server_10G", templateService.getTemplate("GAME",1600L));
Assert.assertEquals("Game_Server_10G", templateService.getTemplate("GAME", (long) 1500.5));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME",1500L));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME",(long) 1499.5));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME", 1L));
Assert.assertEquals("Game_Server_1G", templateService.getTemplate("GAME", 100L));
Assert.assertNull(templateService.getTemplate("GAME",-1L));
log.info("GAME, 0L-----------template: {}", templateService.getTemplate("GAME", 0L));
log.info("GAME, 0.9-----------template: {}", templateService.getTemplate("GAME", (long) 0.9));
Assert.assertEquals("DNS_Server_10G", templateService.getTemplate("DNS",1600L));
Assert.assertEquals("DNS_Server_1G", templateService.getTemplate("DNS",1500L));
Assert.assertEquals("DNS_Server_1G", templateService.getTemplate("DNS",1L));
//Assert.assertEquals("Game_Server_1G", templateService.getTemplate("DNS",0L));
Assert.assertNull(templateService.getTemplate("DNS",-1L));
Assert.assertEquals("WEB_Server_10G", templateService.getTemplate("WEB",1600L));
Assert.assertEquals("WEB_Server_1G", templateService.getTemplate("WEB",1500L));
Assert.assertEquals("WEB_Server_1G", templateService.getTemplate("WEB",1L));
//Assert.assertEquals("Game_Server_1G", templateService.getTemplate("WEB",0L));
Assert.assertNull(templateService.getTemplate("WEB",-1L));
Assert.assertEquals("General_Server_10G", templateService.getTemplate("GENERAL",1600L));
Assert.assertEquals("General_Server_1G", templateService.getTemplate("GENERAL",1500L));
Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",500L));
Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",1L));
//Assert.assertEquals("General_Server_100M", templateService.getTemplate("GENERAL",0L));
Assert.assertNull(templateService.getTemplate("GENERAL",-1L));
Assert.assertNull(templateService.getTemplate("ALL",100L));
}
}