Repository: incubator-griffin Updated Branches: refs/heads/master 6ab05fc20 -> c73349354
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/c7334935/service/src/test/java/org/apache/griffin/core/measure/MeasureServiceImplTest.java ---------------------------------------------------------------------- diff --git a/service/src/test/java/org/apache/griffin/core/measure/MeasureServiceImplTest.java b/service/src/test/java/org/apache/griffin/core/measure/MeasureServiceImplTest.java index 8345a5a..524517a 100644 --- a/service/src/test/java/org/apache/griffin/core/measure/MeasureServiceImplTest.java +++ b/service/src/test/java/org/apache/griffin/core/measure/MeasureServiceImplTest.java @@ -130,8 +130,8 @@ public class MeasureServiceImplTest { Measure measure = createATestMeasure("view_item_hourly", "ebay"); measure.setId(1L); given(measureRepo.findByOwnerAndDeleted(owner, false)).willReturn(Arrays.asList(measure)); - List<Map<String, String>> list = service.getAllAliveMeasureNameIdByOwner(owner); - assertEquals(list.get(0).get("name"), measure.getName()); + List<Measure> list = service.getAliveMeasuresByOwner(owner); + assertEquals(list.get(0).getName(), measure.getName()); } @Test http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/c7334935/service/src/test/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreControllerTest.java ---------------------------------------------------------------------- diff --git a/service/src/test/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreControllerTest.java b/service/src/test/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreControllerTest.java index b2fbc11..b130d26 100644 --- a/service/src/test/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreControllerTest.java +++ b/service/src/test/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreControllerTest.java @@ -58,20 +58,11 @@ public class HiveMetaStoreControllerTest { String dbName = "default"; given(hiveMetaStoreService.getAllDatabases()).willReturn(Arrays.asList(dbName)); - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/db")) + mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/dbs")) .andExpect(status().isOk()) .andExpect(jsonPath("$.[0]", is(dbName))); } - @Test - public void testGetDefAllTables() throws Exception { - String tableName = "table"; - given(hiveMetaStoreService.getAllTableNames("")).willReturn(Arrays.asList(tableName)); - - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/table")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.[0]", is(tableName))); - } @Test public void testGetAllTableNames() throws Exception { @@ -79,7 +70,7 @@ public class HiveMetaStoreControllerTest { String tableName = "table"; given(hiveMetaStoreService.getAllTableNames(dbName)).willReturn(Arrays.asList(tableName)); - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/allTableNames").param("db", dbName)) + mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/tables/names").param("db", dbName)) .andExpect(status().isOk()) .andExpect(jsonPath("$.[0]", is(tableName))); } @@ -89,7 +80,7 @@ public class HiveMetaStoreControllerTest { String dbName = "default"; given(hiveMetaStoreService.getAllTable(dbName)).willReturn(Arrays.asList(new Table())); - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/db/allTables").param("db", dbName)) + mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/tables").param("db", dbName)) .andExpect(status().isOk()) .andExpect(jsonPath("$.[0].tableName", is(nullValue()))); } @@ -100,21 +91,11 @@ public class HiveMetaStoreControllerTest { results.put("table", new ArrayList<>()); given(hiveMetaStoreService.getAllTable()).willReturn(results); - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/allTables")) + mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/dbs/tables")) .andExpect(status().isOk()) .andExpect(jsonPath("$.table", hasSize(0))); } - @Test - public void testGetDefTable() throws Exception { - String dbName = ""; - String tableName = "table"; - given(hiveMetaStoreService.getTable(dbName, tableName)).willReturn(new Table(tableName, null, null, 0, 0, 0, null, null, null, null, null, null)); - - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/default/{table}", tableName)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.tableName", is(tableName))); - } @Test public void testGetTable() throws Exception { @@ -122,7 +103,7 @@ public class HiveMetaStoreControllerTest { String tableName = "table"; given(hiveMetaStoreService.getTable(dbName, tableName)).willReturn(new Table(tableName, null, null, 0, 0, 0, null, null, null, null, null, null)); - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive").param("db", dbName).param("table", tableName)) + mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/metadata/hive/table").param("db", dbName).param("table", tableName)) .andExpect(status().isOk()) .andExpect(jsonPath("$.tableName", is(tableName))); } http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/c7334935/service/src/test/java/org/apache/griffin/core/service/GriffinControllerTest.java ---------------------------------------------------------------------- diff --git a/service/src/test/java/org/apache/griffin/core/service/GriffinControllerTest.java b/service/src/test/java/org/apache/griffin/core/service/GriffinControllerTest.java deleted file mode 100644 index 14f5a52..0000000 --- a/service/src/test/java/org/apache/griffin/core/service/GriffinControllerTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -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.service; - -import org.apache.griffin.core.measure.repo.MeasureRepo; -import org.apache.griffin.core.util.URLHelper; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -import java.util.Arrays; - -import static org.hamcrest.CoreMatchers.is; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - - -@RunWith(SpringRunner.class) -@WebMvcTest(value = GriffinController.class) -public class GriffinControllerTest { - - @Autowired - private MockMvc mockMvc; - - @MockBean - MeasureRepo measureRepo; - - - @Before - public void setup() { - - } - - @Test - public void testGreeting() throws Exception { - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/version")) - .andExpect(status().isOk()) - .andExpect(content().string(is("0.1.0"))); - } - - @Test - public void testGetOrgs() throws Exception { - when(measureRepo.findOrganizations()).thenReturn(Arrays.asList("ebay")); - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/org")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.[0]", is("ebay"))); - } - - @Test - public void testGetMetricNameListByOrg() throws Exception { - String org = "hadoop"; - when(measureRepo.findNameByOrganization(org)).thenReturn(Arrays.asList(org)); - mockMvc.perform(get(URLHelper.API_VERSION_PATH + "/org/{org}", org)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.[0]", is(org))); - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/c7334935/service/src/test/java/org/apache/griffin/core/util/GriffinUtilTest.java ---------------------------------------------------------------------- diff --git a/service/src/test/java/org/apache/griffin/core/util/GriffinUtilTest.java b/service/src/test/java/org/apache/griffin/core/util/GriffinUtilTest.java index 2a86689..192206a 100644 --- a/service/src/test/java/org/apache/griffin/core/util/GriffinUtilTest.java +++ b/service/src/test/java/org/apache/griffin/core/util/GriffinUtilTest.java @@ -40,7 +40,7 @@ public class GriffinUtilTest { @Test public void testToJson() { JobHealth jobHealth = new JobHealth(5, 10); - String jobHealthStr = GriffinUtil.toJson(jobHealth); + String jobHealthStr = JsonUtil.toJson(jobHealth); System.out.println(jobHealthStr); assertEquals(jobHealthStr, "{\"healthyJobCount\":5,\"jobCount\":10}"); } @@ -48,7 +48,7 @@ public class GriffinUtilTest { @Test public void testToEntityWithParamClass() throws IOException { String str = "{\"healthyJobCount\":5,\"jobCount\":10}"; - JobHealth jobHealth = GriffinUtil.toEntity(str, JobHealth.class); + JobHealth jobHealth = JsonUtil.toEntity(str, JobHealth.class); assertEquals(jobHealth.getJobCount(), 10); assertEquals(jobHealth.getHealthyJobCount(), 5); } @@ -58,27 +58,26 @@ public class GriffinUtilTest { String str = "{\"aaa\":12, \"bbb\":13}"; TypeReference<HashMap<String, Integer>> type = new TypeReference<HashMap<String, Integer>>() { }; - Map map = GriffinUtil.toEntity(str, type); + Map map = JsonUtil.toEntity(str, type); assertEquals(map.get("aaa"), 12); } @Test public void testGetPropertiesForSuccess() { - Properties properties = GriffinUtil.getProperties("/quartz.properties"); + Properties properties = PropertiesUtil.getProperties("/quartz.properties"); assertEquals(properties.get("org.quartz.jobStore.isClustered"), "true"); } @Test public void testGetPropertiesForFailWithWrongPath() { - Properties properties = GriffinUtil.getProperties(".././quartz.properties"); + Properties properties = PropertiesUtil.getProperties(".././quartz.properties"); assertEquals(properties, null); } @Test public void testToJsonWithFormat() { JobHealth jobHealth = new JobHealth(5, 10); - String jobHealthStr = GriffinUtil.toJsonWithFormat(jobHealth); + String jobHealthStr = JsonUtil.toJsonWithFormat(jobHealth); System.out.println(jobHealthStr); } - }
