From 1aa3b1ffbdd40f73b937918e353ac6443543b5a7 Mon Sep 17 00:00:00 2001 From: geek Date: Wed, 20 Jun 2018 21:09:13 +0900 Subject: [PATCH] TargetService regist test code --- .../service/CentralTargetServiceTest.java | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/test/java/com/loafle/overflow/central/module/target/service/CentralTargetServiceTest.java diff --git a/src/test/java/com/loafle/overflow/central/module/target/service/CentralTargetServiceTest.java b/src/test/java/com/loafle/overflow/central/module/target/service/CentralTargetServiceTest.java new file mode 100644 index 0000000..740bf2d --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/target/service/CentralTargetServiceTest.java @@ -0,0 +1,78 @@ +package com.loafle.overflow.central.module.target.service; + +import com.loafle.overflow.central.spring.AppConfigTest; +import com.loafle.overflow.core.exception.OverflowException; +import com.loafle.overflow.model.meta.*; +import com.loafle.overflow.model.sensor.Sensor; +import com.loafle.overflow.model.target.Target; +import com.loafle.overflow.service.central.infra.InfraService; +import com.loafle.overflow.service.central.meta.MetaCrawlerService; +import com.loafle.overflow.service.central.meta.MetaSensorStatusService; +import com.loafle.overflow.service.central.target.TargetService; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + + +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("test") +@ContextConfiguration(classes = {AppConfigTest.class}) +public class CentralTargetServiceTest { + + @Autowired + TargetService targetService; + + @Autowired + InfraService infraService; + + @Autowired + MetaCrawlerService metaCrawlerService; + + @Autowired + MetaSensorStatusService metaSensorStatusService; + + @Test + public void regist() { + } + +// List targets, Long probeID + @Test + public void registAll() throws OverflowException { + List targets = new ArrayList<>(); + List sensors = new ArrayList<>(); + + + List metaCrawlers = this.metaCrawlerService.readAll(); + List metaSensorStatusList = this.metaSensorStatusService.readAll(); +// MetaSensorDisplayItem metaSensorDisplayItem = this.metaSensorDisplayItemService.read(Long.valueOf(1)); + + Target target = new Target(); + target.setMetaTargetType(MetaTargetServiceType.Enum.UNKNOWN.to()); + target.setInfra(new com.loafle.overflow.model.infra.InfraService(Long.valueOf((long)3))); + + Sensor sensor = new Sensor(); + sensor.setItemCount(0); + sensor.setCrawlerInputItems(null); + sensor.setMetaCrawler(metaCrawlers.get(5)); + sensor.setName("Test Sensor"); + sensor.setTarget(target); + sensor.setMetaSensorStatus(metaSensorStatusList.get(0)); + + sensors.add(sensor); + + target.setSensors(sensors); + + targets.add(target); + List targetList = this.targetService.registAll(targets, Long.valueOf(1)); + + System.out.println("Target List Size: " + targetList.size()); + } +}