You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@griffin.apache.org by gu...@apache.org on 2018/07/18 09:51:59 UTC
incubator-griffin git commit: Fix bug and enable new test cases to
verify GriffinMeasureOperatorImpl
Repository: incubator-griffin
Updated Branches:
refs/heads/master 37a63b466 -> 504f827da
Fix bug and enable new test cases to verify GriffinMeasureOperatorImpl
Author: Eugene <to...@163.com>
Closes #355 from toyboxman/bug/fixing.
Project: http://git-wip-us.apache.org/repos/asf/incubator-griffin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-griffin/commit/504f827d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-griffin/tree/504f827d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-griffin/diff/504f827d
Branch: refs/heads/master
Commit: 504f827dac3b4d38ddcdf9d1d277a5b46a891807
Parents: 37a63b4
Author: Eugene <to...@163.com>
Authored: Wed Jul 18 17:51:53 2018 +0800
Committer: William Guo <gu...@apache.org>
Committed: Wed Jul 18 17:51:53 2018 +0800
----------------------------------------------------------------------
.../measure/GriffinMeasureOperatorImplTest.java | 218 +++++++++----------
1 file changed, 109 insertions(+), 109 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/504f827d/service/src/test/java/org/apache/griffin/core/measure/GriffinMeasureOperatorImplTest.java
----------------------------------------------------------------------
diff --git a/service/src/test/java/org/apache/griffin/core/measure/GriffinMeasureOperatorImplTest.java b/service/src/test/java/org/apache/griffin/core/measure/GriffinMeasureOperatorImplTest.java
index 3d99d71..f237a6c 100644
--- a/service/src/test/java/org/apache/griffin/core/measure/GriffinMeasureOperatorImplTest.java
+++ b/service/src/test/java/org/apache/griffin/core/measure/GriffinMeasureOperatorImplTest.java
@@ -1,109 +1,109 @@
-///*
-//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.griffin.core.measure;
-//
-//import org.apache.griffin.core.exception.GriffinException;
-//import org.apache.griffin.core.job.JobServiceImpl;
-//import org.apache.griffin.core.measure.entity.DataConnector;
-//import org.apache.griffin.core.measure.entity.GriffinMeasure;
-//import org.apache.griffin.core.measure.entity.Measure;
-//import org.apache.griffin.core.measure.repo.DataConnectorRepo;
-//import org.apache.griffin.core.measure.repo.MeasureRepo;
-//import org.junit.Before;
-//import org.junit.Test;
-//import org.junit.runner.RunWith;
-//import org.mockito.InjectMocks;
-//import org.mockito.Mock;
-//import org.springframework.test.context.junit4.SpringRunner;
-//
-//import static org.apache.griffin.core.util.EntityHelper.createDataConnector;
-//import static org.apache.griffin.core.util.EntityHelper.createGriffinMeasure;
-//import static org.junit.Assert.assertEquals;
-//import static org.mockito.BDDMockito.given;
-//import static org.mockito.Mockito.*;
-//
-//@RunWith(SpringRunner.class)
-//public class GriffinMeasureOperatorImplTest {
-//
-// @InjectMocks
-// private GriffinMeasureOperationImpl operation;
-//
-// @Mock
-// private MeasureRepo<Measure> measureRepo;
-// @Mock
-// private DataConnectorRepo dcRepo;
-// @Mock
-// private JobServiceImpl jobService;
-//
-//
-// @Before
-// public void setup() {
-// }
-//
-// @Test
-// public void testCreateForSuccess() throws Exception {
-// Measure measure = createGriffinMeasure("view_item_hourly");
-// given(measureRepo.save(measure)).willReturn(measure);
-//
-// Measure m = operation.create(measure);
-// assertEquals(m.getName(), measure.getName());
-// }
-//
-// @Test(expected = GriffinException.BadRequestException.class)
-// public void testCreateForFailureWithConnectorNull() throws Exception {
-// String measureName = "view_item_hourly";
-// DataConnector dcSource = createDataConnector(null, "default", "test_data_src", "dt=#YYYYMMdd# AND hour=#HH#");
-// DataConnector dcTarget = createDataConnector(null, "default", "test_data_tgt", "dt=#YYYYMMdd# AND hour=#HH#");
-// GriffinMeasure measure = createGriffinMeasure(measureName, dcSource, dcTarget);
-//
-// operation.create(measure);
-// }
-//
-// @Test
-// public void testUpdateForSuccess() throws Exception {
-// Measure measure = createGriffinMeasure("view_item_hourly");
-// given(measureRepo.save(measure)).willReturn(measure);
-//
-// operation.update(measure);
-// verify(measureRepo, times(1)).save(measure);
-// }
-//
-// @Test
-// public void testDeleteForSuccess() throws Exception {
-// Measure measure = createGriffinMeasure("view_item_hourly");
-// measure.setId(1L);
-// doNothing().when(jobService).deleteJobsRelateToMeasure(1L);
-// given(measureRepo.save(measure)).willReturn(measure);
-//
-// operation.update(measure);
-// verify(measureRepo, times(1)).save(measure);
-// }
-//
-// @Test(expected = GriffinException.ServiceException.class)
-// public void testDeleteForFailureWithPauseJob() throws Exception {
-// Measure measure = createGriffinMeasure("view_item_hourly");
-// measure.setId(1L);
-// doThrow(new GriffinException.ServiceException("Service exception", new RuntimeException()))
-// .when(jobService).deleteJobsRelateToMeasure(1L);
-//
-// operation.delete(measure);
-// }
-//
-//}
+/*
+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.griffin.core.measure;
+
+import org.apache.griffin.core.exception.GriffinException;
+import org.apache.griffin.core.job.JobServiceImpl;
+import org.apache.griffin.core.measure.entity.DataConnector;
+import org.apache.griffin.core.measure.entity.GriffinMeasure;
+import org.apache.griffin.core.measure.entity.Measure;
+import org.apache.griffin.core.measure.repo.DataConnectorRepo;
+import org.apache.griffin.core.measure.repo.MeasureRepo;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import static org.apache.griffin.core.util.EntityHelper.createDataConnector;
+import static org.apache.griffin.core.util.EntityHelper.createGriffinMeasure;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.*;
+
+@RunWith(SpringRunner.class)
+public class GriffinMeasureOperatorImplTest {
+
+ @InjectMocks
+ private GriffinMeasureOperatorImpl operator;
+
+ @Mock
+ private MeasureRepo<Measure> measureRepo;
+ @Mock
+ private DataConnectorRepo dcRepo;
+ @Mock
+ private JobServiceImpl jobService;
+
+
+ @Before
+ public void setup() {
+ }
+
+ @Test
+ public void testCreateForSuccess() throws Exception {
+ Measure measure = createGriffinMeasure("view_item_hourly");
+ given(measureRepo.save(measure)).willReturn(measure);
+
+ Measure m = operator.create(measure);
+ assertEquals(m.getName(), measure.getName());
+ }
+
+ @Test(expected = GriffinException.BadRequestException.class)
+ public void testCreateForFailureWithConnectorNull() throws Exception {
+ String measureName = "view_item_hourly";
+ DataConnector dcSource = createDataConnector(null, "default", "test_data_src", "dt=#YYYYMMdd# AND hour=#HH#");
+ DataConnector dcTarget = createDataConnector(null, "default", "test_data_tgt", "dt=#YYYYMMdd# AND hour=#HH#");
+ GriffinMeasure measure = createGriffinMeasure(measureName, dcSource, dcTarget);
+
+ operator.create(measure);
+ }
+
+ @Test
+ public void testUpdateForSuccess() throws Exception {
+ Measure measure = createGriffinMeasure("view_item_hourly");
+ given(measureRepo.save(measure)).willReturn(measure);
+
+ operator.update(measure);
+ verify(measureRepo, times(1)).save(measure);
+ }
+
+ @Test
+ public void testDeleteForSuccess() throws Exception {
+ Measure measure = createGriffinMeasure("view_item_hourly");
+ measure.setId(1L);
+ doNothing().when(jobService).deleteJobsRelateToMeasure(1L);
+ given(measureRepo.save(measure)).willReturn(measure);
+
+ operator.update(measure);
+ verify(measureRepo, times(1)).save(measure);
+ }
+
+ @Test(expected = GriffinException.ServiceException.class)
+ public void testDeleteForFailureWithPauseJob() throws Exception {
+ Measure measure = createGriffinMeasure("view_item_hourly");
+ measure.setId(1L);
+ doThrow(new GriffinException.ServiceException("Service exception", new RuntimeException()))
+ .when(jobService).deleteJobsRelateToMeasure(1L);
+
+ operator.delete(measure);
+ }
+
+}