[GitHub] wu-sheng commented on a change in pull request #1079: apm collector ui module testcase completed

2018-04-16 Thread GitBox
wu-sheng commented on a change in pull request #1079: apm collector ui module 
testcase completed
URL: 
https://github.com/apache/incubator-skywalking/pull/1079#discussion_r181938350
 
 

 ##
 File path: 
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/service/TraceStackServiceTest.java
 ##
 @@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.skywalking.apm.collector.ui.service;
+
+import com.google.common.collect.Lists;
+import 
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
+import 
org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService;
+import 
org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
+import org.apache.skywalking.apm.collector.core.module.MockModule;
+import org.apache.skywalking.apm.collector.core.module.ModuleManager;
+import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO;
+import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO;
+import org.apache.skywalking.apm.collector.storage.table.register.Application;
+import org.apache.skywalking.apm.collector.storage.ui.trace.Trace;
+import org.apache.skywalking.apm.network.proto.*;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+/**
+ * @author lican
+ */
+public class TraceStackServiceTest {
+
+private TraceStackService traceStackService;
+private IGlobalTraceUIDAO globalTraceDAO;
+private ISegmentUIDAO segmentDAO;
+private ApplicationCacheService applicationCacheService;
+private ServiceNameCacheService serviceNameCacheService;
+private NetworkAddressCacheService networkAddressCacheService;
+
+@Before
+public void setUp() throws Exception {
+ModuleManager moduleManager = mock(ModuleManager.class);
+when(moduleManager.find(anyString())).then(invocation -> new 
MockModule());
+traceStackService = new TraceStackService(moduleManager);
+globalTraceDAO = mock(IGlobalTraceUIDAO.class);
+segmentDAO = mock(ISegmentUIDAO.class);
+applicationCacheService = mock(ApplicationCacheService.class);
+Whitebox.setInternalState(traceStackService, "globalTraceDAO", 
globalTraceDAO);
+Whitebox.setInternalState(traceStackService, "segmentDAO", segmentDAO);
+Whitebox.setInternalState(traceStackService, 
"applicationCacheService", applicationCacheService);
+}
+
+@Test
+public void load() {
 
 Review comment:
   `TraceStackService` will be changed totally by me, today. So I prefer to 
merge these test cases before that.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] wu-sheng commented on a change in pull request #1079: apm collector ui module testcase completed

2018-04-16 Thread GitBox
wu-sheng commented on a change in pull request #1079: apm collector ui module 
testcase completed
URL: 
https://github.com/apache/incubator-skywalking/pull/1079#discussion_r181938234
 
 

 ##
 File path: 
apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilderTest.java
 ##
 @@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.skywalking.apm.collector.ui.service;
+
+import 
org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
+import org.apache.skywalking.apm.collector.core.module.MockModule;
+import org.apache.skywalking.apm.collector.core.module.ModuleManager;
+import 
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO;
+import 
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO;
+import 
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMetricUIDAO;
+import 
org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO;
+import org.apache.skywalking.apm.collector.storage.table.register.Application;
+import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm;
+import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmItem;
+import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
+import org.apache.skywalking.apm.collector.storage.ui.common.Step;
+import org.apache.skywalking.apm.collector.storage.ui.common.Topology;
+import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.Whitebox;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.mock;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+/**
+ * @author lican
+ */
+public class TopologyBuilderTest {
+
+private ApplicationCacheService applicationCacheService;
+private ServerService serverService;
+private SecondBetweenService secondBetweenService;
+private AlarmService alarmService;
+private TopologyBuilder topologyBuilder;
+private Duration duration;
+private long startSecondTimeBucket;
+private long endSecondTimeBucket;
+private long startTimeBucket;
+private long endTimeBucket;
+
+@Before
+public void setUp() throws Exception {
+ModuleManager moduleManager = mock(ModuleManager.class);
+when(moduleManager.find(anyString())).then(invocation -> new 
MockModule());
+topologyBuilder = new TopologyBuilder(moduleManager);
+applicationCacheService = mock(ApplicationCacheService.class);
+alarmService = mock(AlarmService.class);
+secondBetweenService = mock(SecondBetweenService.class);
+Whitebox.setInternalState(topologyBuilder, "applicationCacheService", 
applicationCacheService);
+Whitebox.setInternalState(topologyBuilder, "alarmService", 
alarmService);
+Whitebox.setInternalState(topologyBuilder, "secondBetweenService", 
secondBetweenService);
+duration = new Duration();
+duration.setEnd("2018-02");
+duration.setStart("2018-01");
+duration.setStep(Step.MONTH);
+startSecondTimeBucket = 
DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getStart());
+endSecondTimeBucket = 
DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(duration.getStep(), 
duration.getEnd());
+startTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart());
+endTimeBucket = 
DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd());
+}
+
+@Test
+public void build() throws ParseException {
 
 Review comment:
   @peng-yongsheng You can feel relax about these type test cases. I agree, on 
one can be easy to mock topology and trace related test cases. We can count on 
your automatic backend test to cover these.


This is an automated message