diff --git a/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/LookupService.java b/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/LookupService.java index 14b41e5fe..ab1b06343 100644 --- a/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/LookupService.java +++ b/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/LookupService.java @@ -106,7 +106,7 @@ default Lookup addValues(final String name, final Set values, boolean in * @return updated lookup */ @Nullable - default Lookup setValues(final String name, final Set values, final boolean includeValues) { + default Lookup setValues(final String name, final Set values) { return null; } } diff --git a/metacat-functional-tests/build.gradle b/metacat-functional-tests/build.gradle index 3d64cc971..ab9f9693c 100644 --- a/metacat-functional-tests/build.gradle +++ b/metacat-functional-tests/build.gradle @@ -42,6 +42,7 @@ configurations { dependencies { + testImplementation project(path: ':metacat-metadata-mysql') warproject(project(path: ':metacat-war', configuration: 'archives')) /******************************* @@ -64,7 +65,6 @@ dependencies { testImplementation(project(":metacat-common-server")) testImplementation(project(":metacat-connector-hive")) testImplementation(project(":metacat-testdata-provider")) - functionalTestImplementation(project(":metacat-client")) functionalTestImplementation("org.apache.hadoop:hadoop-core") functionalTestImplementation("org.apache.hive:hive-exec:${hive_version}") { diff --git a/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/MySqlLookupServiceSpec.groovy b/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/MySqlLookupServiceSpec.groovy new file mode 100644 index 000000000..42786c22c --- /dev/null +++ b/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/MySqlLookupServiceSpec.groovy @@ -0,0 +1,60 @@ +/* + * Copyright 2016 Netflix, Inc. + * + * Licensed 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 com.netflix.metacat + +import com.netflix.metacat.common.server.properties.DefaultConfigImpl +import com.netflix.metacat.common.server.properties.MetacatProperties +import com.netflix.metacat.metadata.mysql.MySqlLookupService +import org.springframework.jdbc.core.JdbcTemplate +import org.springframework.jdbc.datasource.DriverManagerDataSource +import spock.lang.Shared +import spock.lang.Specification + +class MySqlLookupServiceUnitTest extends Specification{ + private MySqlLookupService mySqlLookupService; + private JdbcTemplate jdbcTemplate; + + @Shared + MySqlLookupService mySqlLookupService + + @Shared + JdbcTemplate jdbcTemplate + + def setupSpec() { + String jdbcUrl = "jdbc:mysql://localhost:3306/metacat" // adjust host if necessary + String username = "metacat_user" + String password = "metacat_user_password" + + DriverManagerDataSource dataSource = new DriverManagerDataSource() + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver") + dataSource.setUrl(jdbcUrl) + dataSource.setUsername(username) + dataSource.setPassword(password) + + jdbcTemplate = new JdbcTemplate(dataSource) + mySqlLookupService = new MySqlLookupService(new DefaultConfigImpl(new MetacatProperties()), jdbcTemplate) + // ... additional setup + } + + def "test get method"() { + when: + def lookup = mySqlLookupService.setValues("mock", ["1", "2", "3"] as Set) + then: + lookup.values.size() == 3 + } +} + diff --git a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlLookupService.java b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlLookupService.java index f9702efff..4bfdd96f0 100644 --- a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlLookupService.java +++ b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlLookupService.java @@ -242,9 +242,11 @@ public Lookup addValues(final String name, final Set values, final boole * @return returns the lookup with the given name. */ @Override - public Lookup setValues(final String name, final Set values, final boolean includeValues) { + public Lookup setValues(final String name, final Set values) { try { - final Lookup lookup = findOrCreateLookupByName(name, includeValues); + // For set values, no need to include values from querying rds + // since the values will be the same as the input values + final Lookup lookup = findOrCreateLookupByName(name, false); if (!values.isEmpty()) { insertLookupValuesIfNotExist(lookup.getId(), values); deleteLookupValuesIfNotIn(lookup.getId(), values);