parent
c3552d4654
commit
771c82e282
|
@ -19,7 +19,7 @@
|
|||
INSERT IGNORE INTO service_group(serviceId, serviceType, serviceBandwidth, serviceIp)
|
||||
VALUES
|
||||
<foreach collection="svrGrps" item="svg" separator=",">
|
||||
(#{svg.deviceId}, #{svg.serviceType}, #{svg.serviceBandwidth}, #{svg.serviceIp})
|
||||
(#{svg.serviceId}, #{svg.serviceType}, #{svg.serviceBandwidth}, #{svg.serviceIp})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
package com.dispose.test.dev.mapper;
|
||||
|
||||
import com.dispose.mapper.ServiceGroupMapper;
|
||||
import com.dispose.pojo.entity.ServiceInfo;
|
||||
import com.dispose.test.dev.Global.InitTestEnvironment;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Slf4j
|
||||
//@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
//@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
@Transactional
|
||||
@Rollback
|
||||
public class ServiceGroupMapperTest extends InitTestEnvironment {
|
||||
/**
|
||||
* The service group mapper.
|
||||
*/
|
||||
@Resource
|
||||
private ServiceGroupMapper serviceGroupMapper;
|
||||
/**
|
||||
* The Object mapper.
|
||||
*/
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* A 1 add new service group.
|
||||
*
|
||||
* @throws JsonProcessingException the json processing exception
|
||||
*/
|
||||
@Test
|
||||
public void a1_addServiceGroup() throws JsonProcessingException{
|
||||
List<ServiceInfo> service = new ArrayList<>();
|
||||
service.add(ServiceInfo.builder()
|
||||
.serviceId("100")
|
||||
.serviceType("GAME")
|
||||
.serviceBandwidth(1000L)
|
||||
.serviceIp("192.168.100.1-192.168.100.10,192.168.100.20-192.168.100.21")
|
||||
.build());
|
||||
service.add(ServiceInfo.builder()
|
||||
.serviceId("101")
|
||||
.serviceType("DNS")
|
||||
.serviceBandwidth(2000L)
|
||||
.serviceIp("192.168.101.1-192.168.101.10")
|
||||
.build());
|
||||
|
||||
int num = serviceGroupMapper.addServiceGroup(service);
|
||||
Assert.assertEquals(num, service.size());
|
||||
log.info("add num {}: {}", num, objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(service));
|
||||
|
||||
List<ServiceInfo> serviceList = serviceGroupMapper.selectAll();
|
||||
Assert.assertNotNull(serviceList);
|
||||
Assert.assertNotEquals(serviceList.size(), 0);
|
||||
|
||||
log.info("Database: {}", objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(serviceList));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue