mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-24 14:08:45 +00:00
Merge pull request #58 from open-metadata/checkstyle_changes
Checkstyle; Include test files for checkstyle, removed AvoidWildcard,…
This commit is contained in:
commit
f765bfe4a3
@ -35,7 +35,6 @@ import org.openmetadata.catalog.resources.databases.TableResource;
|
||||
import org.openmetadata.catalog.type.Column;
|
||||
import org.openmetadata.catalog.type.DailyCount;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TableJoins;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package org.openmetadata.catalog.resources;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.openmetadata.catalog.resources.databases.TableResource.TableList;
|
||||
import org.openmetadata.catalog.type.CollectionDescriptor;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
@ -24,7 +24,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import org.openmetadata.catalog.CatalogApplicationConfig;
|
||||
import org.openmetadata.catalog.resources.Collection;
|
||||
import org.openmetadata.catalog.security.AuthenticationConfiguration;
|
||||
import org.openmetadata.catalog.type.CollectionDescriptor;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@ -147,7 +147,8 @@ public class TableResource {
|
||||
@QueryParam("before") String before,
|
||||
@Parameter(description = "Returns list of tables after this curor",
|
||||
schema = @Schema(type = "string"))
|
||||
@QueryParam("after") String after) throws IOException, ParseException, GeneralSecurityException {
|
||||
@QueryParam("after") String after)
|
||||
throws IOException, ParseException, GeneralSecurityException {
|
||||
RestUtil.validateCursors(before, after);
|
||||
Fields fields = new Fields(FIELD_LIST, fieldsParam);
|
||||
|
||||
@ -350,7 +351,7 @@ public class TableResource {
|
||||
@PUT
|
||||
@Path("/{id}/sampleData")
|
||||
@Operation(summary = "Add sample data", tags = "tables",
|
||||
description = "Add sample data to the table." )
|
||||
description = "Add sample data to the table.")
|
||||
public Table addSampleData(@Context UriInfo uriInfo,
|
||||
@Context SecurityContext securityContext,
|
||||
@Parameter(description = "Id of the table", schema = @Schema(type = "string"))
|
||||
|
||||
@ -99,9 +99,9 @@ public class TeamResource {
|
||||
|
||||
static class TeamList extends ResultList<Team> {
|
||||
@SuppressWarnings("unused") /* Required for tests */
|
||||
public TeamList() {}
|
||||
TeamList() {}
|
||||
|
||||
public TeamList(List<Team> teams, int limitParam, String beforeCursor, String afterCursor)
|
||||
TeamList(List<Team> teams, int limitParam, String beforeCursor, String afterCursor)
|
||||
throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
super(teams, limitParam, beforeCursor, afterCursor);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public class UserResource {
|
||||
@SuppressWarnings("unused") // Used for deserialization
|
||||
UserList() {}
|
||||
|
||||
public UserList(List<User> users, int limitParam, String beforeCursor, String afterCursor)
|
||||
UserList(List<User> users, int limitParam, String beforeCursor, String afterCursor)
|
||||
throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
super(users, limitParam, beforeCursor, afterCursor);
|
||||
}
|
||||
|
||||
@ -35,7 +35,9 @@ public class AuthenticationConfiguration {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public String getPublicKey() { return publicKey; }
|
||||
public String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public void setPublicKey(String publicKey) {
|
||||
this.publicKey = publicKey;
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog;
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog;
|
||||
|
||||
import org.openmetadata.catalog.jdbi3.Relationship;
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources;
|
||||
|
||||
import com.wix.mysql.EmbeddedMysql;
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.databases;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@ -171,7 +187,7 @@ public class DatabaseResourceTest extends CatalogApplicationTest {
|
||||
|
||||
@Test
|
||||
public void post_databaseWithDifferentService_200_ok(TestInfo test) throws HttpResponseException {
|
||||
EntityReference[] differentServices = { MYSQL_REFERENCE, REDSHIFT_REFERENCE, BIGQUERY_REFERENCE,
|
||||
EntityReference[] differentServices = {MYSQL_REFERENCE, REDSHIFT_REFERENCE, BIGQUERY_REFERENCE,
|
||||
SNOWFLAKE_REFERENCE};
|
||||
|
||||
// Create database for each service and test APIs
|
||||
@ -219,7 +235,8 @@ public class DatabaseResourceTest extends CatalogApplicationTest {
|
||||
}
|
||||
|
||||
// List all databases
|
||||
DatabaseList allDatabases = listDatabases(null, null, 1000000, null, null, adminAuthHeaders());
|
||||
DatabaseList allDatabases = listDatabases(null, null, 1000000, null,
|
||||
null, adminAuthHeaders());
|
||||
int totalRecords = allDatabases.getData().size();
|
||||
printDatabases(allDatabases);
|
||||
|
||||
@ -253,7 +270,7 @@ public class DatabaseResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// We have now reached the last page - test backward scroll till the beginning
|
||||
pageCount = 0;
|
||||
indexInAllDatabases = totalRecords - limit - forwardPage.getData().size() ;
|
||||
indexInAllDatabases = totalRecords - limit - forwardPage.getData().size();
|
||||
do {
|
||||
LOG.info("Limit {} backward scrollCount {} beforeCursor {}", limit, pageCount, before);
|
||||
forwardPage = listDatabases(null, null, limit, before, null, adminAuthHeaders());
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.databases;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@ -431,7 +447,8 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
validateColumnJoins(expectedJoins3, table3.getJoins());
|
||||
|
||||
// Report again for the previous day and make sure aggregate counts are correct
|
||||
table1Joins = new TableJoins().withDayCount(1).withStartDate(RestUtil.today(-1)).withColumnJoins(reportedJoins);
|
||||
table1Joins = new TableJoins().withDayCount(1).withStartDate(RestUtil.today(-1))
|
||||
.withColumnJoins(reportedJoins);
|
||||
putJoins(table1.getId(), table1Joins, adminAuthHeaders());
|
||||
table1 = getTable(table1.getId(), "joins", adminAuthHeaders());
|
||||
}
|
||||
@ -542,7 +559,8 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
tableData.withColumns(columns).withRows(rows);
|
||||
exception = assertThrows(HttpResponseException.class, () ->
|
||||
putSampleData(table.getId(), tableData, adminAuthHeaders()));
|
||||
TestUtils.assertResponseContains(exception, BAD_REQUEST, "Number of columns is 3 but row has 4 sample values");
|
||||
TestUtils.assertResponseContains(exception, BAD_REQUEST, "Number of columns is 3 but row " +
|
||||
"has 4 sample values");
|
||||
|
||||
// Send sample data that has less samples than the number of columns
|
||||
columns = Arrays.asList("c1", "c2", "c3"); // Invalid column name
|
||||
@ -550,7 +568,8 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
tableData.withColumns(columns).withRows(rows);
|
||||
exception = assertThrows(HttpResponseException.class, () ->
|
||||
putSampleData(table.getId(), tableData, adminAuthHeaders()));
|
||||
TestUtils.assertResponseContains(exception, BAD_REQUEST, "Number of columns is 3 but row has 2 sample values");
|
||||
TestUtils.assertResponseContains(exception, BAD_REQUEST, "Number of columns is 3 but row h" +
|
||||
"as 2 sample values");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -613,7 +632,7 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// GET .../tables?fields=usageSummary,owner,service
|
||||
fields = "usageSummary,owner,database";
|
||||
tableList = listTables( fields, null, adminAuthHeaders());
|
||||
tableList = listTables(fields, null, adminAuthHeaders());
|
||||
assertEquals(2, tableList.getData().size());
|
||||
assertFields(tableList.getData(), fields);
|
||||
for (Table table : tableList.getData()) {
|
||||
@ -668,7 +687,8 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
}
|
||||
|
||||
// List all tables and use it for checking pagination
|
||||
TableList allTables = listTables(null, null, 1000000, null, null, adminAuthHeaders());
|
||||
TableList allTables = listTables(null, null, 1000000, null, null,
|
||||
adminAuthHeaders());
|
||||
int totalRecords = allTables.getData().size();
|
||||
printTables(allTables);
|
||||
|
||||
@ -703,7 +723,7 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// We have now reached the last page - test backward scroll till the beginning
|
||||
pageCount = 0;
|
||||
indexInAllTables = totalRecords - limit - forwardPage.getData().size() ;
|
||||
indexInAllTables = totalRecords - limit - forwardPage.getData().size();
|
||||
do {
|
||||
LOG.info("Limit {} backward scrollCount {} beforeCursor {}", limit, pageCount, before);
|
||||
forwardPage = listTables(null, null, limit, before, null, adminAuthHeaders());
|
||||
@ -763,12 +783,13 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
tableConstraints = List.of(new TableConstraint().withConstraintType(ConstraintType.UNIQUE)
|
||||
.withColumns(List.of(COLUMNS.get(1).getName())));
|
||||
tableTags = singletonList(USER_BANK_ACCOUNT_TAG_LABEL);
|
||||
table = patchTableAttributesAndCheck(table, "description1", USER_OWNER1, TableType.External, tableConstraints,
|
||||
tableTags, adminAuthHeaders());
|
||||
table = patchTableAttributesAndCheck(table, "description1", USER_OWNER1, TableType.External,
|
||||
tableConstraints, tableTags, adminAuthHeaders());
|
||||
table.setOwner(USER_OWNER1); // Get rid of href and name returned in the response for owner
|
||||
|
||||
// Remove description, tier, owner, tableType, tableConstraints
|
||||
patchTableAttributesAndCheck(table, null, null, null, null, null, adminAuthHeaders());
|
||||
patchTableAttributesAndCheck(table, null, null, null, null, null,
|
||||
adminAuthHeaders());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -866,7 +887,8 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// Validate information returned in patch response has the updates
|
||||
Table updatedTable = patchTable(tableJson, table, authHeaders);
|
||||
validateTable(updatedTable, table.getDescription(), owner, null, tableType, tableConstraints, tags);
|
||||
validateTable(updatedTable, table.getDescription(), owner, null, tableType,
|
||||
tableConstraints, tags);
|
||||
|
||||
// GET the table and Validate information returned
|
||||
Table getTable = getTable(table.getId(), "owner,tableConstraints,tags", authHeaders);
|
||||
@ -904,10 +926,14 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
void assertFields(Table table, String fieldsParam) {
|
||||
Fields fields = new Fields(TableResource.FIELD_LIST, fieldsParam);
|
||||
|
||||
if (fields.contains("usageSummary")) {assertNotNull(table.getUsageSummary());} else {
|
||||
if (fields.contains("usageSummary")) {
|
||||
assertNotNull(table.getUsageSummary());
|
||||
} else {
|
||||
assertNull(table.getUsageSummary());
|
||||
}
|
||||
if (fields.contains("owner")) {assertNotNull(table.getOwner());} else {
|
||||
if (fields.contains("owner")) {
|
||||
assertNotNull(table.getOwner());
|
||||
} else {
|
||||
assertNull(table.getOwner());
|
||||
}
|
||||
if (fields.contains("columns")) {
|
||||
@ -920,10 +946,14 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
} else {
|
||||
assertNull(table.getColumns());
|
||||
}
|
||||
if (fields.contains("tableConstraints")) {assertNotNull(table.getTableConstraints());} else {
|
||||
if (fields.contains("tableConstraints")) {
|
||||
assertNotNull(table.getTableConstraints());
|
||||
} else {
|
||||
assertNull(table.getTableConstraints());
|
||||
}
|
||||
if (fields.contains("database")) {assertNotNull(table.getDatabase());} else {
|
||||
if (fields.contains("database")) {
|
||||
assertNotNull(table.getDatabase());
|
||||
} else {
|
||||
assertNull(table.getDatabase());
|
||||
}
|
||||
if (fields.contains("tags")) {
|
||||
@ -956,7 +986,8 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
assertEquals(table.getDatabase().getName(), DATABASE.getName());
|
||||
}
|
||||
|
||||
private static void validateTags(List<TagLabel> expectedList, List<TagLabel> actualList) throws HttpResponseException {
|
||||
private static void validateTags(List<TagLabel> expectedList, List<TagLabel> actualList)
|
||||
throws HttpResponseException {
|
||||
if (expectedList == null) {
|
||||
return;
|
||||
}
|
||||
@ -1083,7 +1114,8 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
|
||||
public static Table updateTable(CreateTable create, Status status, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
return TestUtils.put(CatalogApplicationTest.getResource("tables"), create, Table.class, status, authHeaders);
|
||||
return TestUtils.put(CatalogApplicationTest.getResource("tables"), create, Table.class,
|
||||
status, authHeaders);
|
||||
}
|
||||
|
||||
public static void putJoins(UUID tableId, TableJoins joins, Map<String, String> authHeaders)
|
||||
@ -1110,7 +1142,8 @@ public class TableResourceTest extends CatalogApplicationTest {
|
||||
Map<String, String> authHeaders) throws JsonProcessingException, HttpResponseException {
|
||||
String updateTableJson = JsonUtils.pojoToJson(updatedTable);
|
||||
JsonPatch patch = JsonSchemaUtil.getJsonPatch(originalJson, updateTableJson);
|
||||
return TestUtils.patch(CatalogApplicationTest.getResource("tables/" + tableId), patch, Table.class, authHeaders);
|
||||
return TestUtils.patch(CatalogApplicationTest.getResource("tables/" + tableId),
|
||||
patch, Table.class, authHeaders);
|
||||
}
|
||||
|
||||
private Table patchTable(String originalJson, Table updatedTable,
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.feeds;
|
||||
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.feeds;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.services;
|
||||
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
@ -76,7 +92,8 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
|
||||
HttpResponseException exception = assertThrows(HttpResponseException.class, () ->
|
||||
createAndCheckService(create(test, 1).withDescription(null), authHeaders));
|
||||
TestUtils.assertResponse(exception, FORBIDDEN, "Principal: CatalogPrincipal{name='test'} is not admin");
|
||||
TestUtils.assertResponse(exception, FORBIDDEN,
|
||||
"Principal: CatalogPrincipal{name='test'} is not admin");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -104,17 +121,20 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
create.withIngestionSchedule(schedule.withRepeatFrequency("P1Y"));
|
||||
exception = assertThrows(HttpResponseException.class, () -> createService(create, adminAuthHeaders()));
|
||||
TestUtils.assertResponse(exception, BAD_REQUEST,
|
||||
"Ingestion repeatFrequency can only contain Days, Hours, and Minutes - example P{d}DT{h}H{m}M");
|
||||
"Ingestion repeatFrequency can only contain Days, Hours, " +
|
||||
"and Minutes - example P{d}DT{h}H{m}M");
|
||||
|
||||
create.withIngestionSchedule(schedule.withRepeatFrequency("P1M"));
|
||||
exception = assertThrows(HttpResponseException.class, () -> createService(create, adminAuthHeaders()));
|
||||
TestUtils.assertResponse(exception, BAD_REQUEST,
|
||||
"Ingestion repeatFrequency can only contain Days, Hours, and Minutes - example P{d}DT{h}H{m}M");
|
||||
"Ingestion repeatFrequency can only contain Days, Hours, " +
|
||||
"and Minutes - example P{d}DT{h}H{m}M");
|
||||
|
||||
create.withIngestionSchedule(schedule.withRepeatFrequency("PT1S"));
|
||||
exception = assertThrows(HttpResponseException.class, () -> createService(create, adminAuthHeaders()));
|
||||
TestUtils.assertResponse(exception, BAD_REQUEST,
|
||||
"Ingestion repeatFrequency can only contain Days, Hours, and Minutes - example P{d}DT{h}H{m}M");
|
||||
"Ingestion repeatFrequency can only contain Days, Hours, " +
|
||||
"and Minutes - example P{d}DT{h}H{m}M");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -143,7 +163,8 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
|
||||
create.withIngestionSchedule(schedule.withRepeatFrequency("PT59M")); // Repeat every 50 minutes 59 seconds
|
||||
exception = assertThrows(HttpResponseException.class, () -> createService(create, adminAuthHeaders()));
|
||||
TestUtils.assertResponse(exception, BAD_REQUEST, "Ingestion repeatFrequency is too short and must be more than 60 minutes");
|
||||
TestUtils.assertResponse(exception, BAD_REQUEST, "Ingestion repeatFrequency is too short and must " +
|
||||
"be more than 60 minutes");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -152,12 +173,14 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
UpdateDatabaseService update = new UpdateDatabaseService().withDescription("description1");
|
||||
HttpResponseException exception = assertThrows(HttpResponseException.class, ()
|
||||
-> updateDatabaseService(TestUtils.NON_EXISTENT_ENTITY.toString(), update, OK, adminAuthHeaders()));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND, CatalogExceptionMessage.entityNotFound("DatabaseService", TestUtils.NON_EXISTENT_ENTITY));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND, CatalogExceptionMessage.entityNotFound("DatabaseService",
|
||||
TestUtils.NON_EXISTENT_ENTITY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void put_updateDatabaseService_as_admin_2xx(TestInfo test) throws HttpResponseException {
|
||||
DatabaseService dbService = createAndCheckService(create(test).withDescription(null).withIngestionSchedule(null), adminAuthHeaders());
|
||||
DatabaseService dbService = createAndCheckService(create(test).withDescription(null).withIngestionSchedule(null),
|
||||
adminAuthHeaders());
|
||||
String id = dbService.getId().toString();
|
||||
String startDate = RestUtil.DATE_TIME_FORMAT.format(new Date());
|
||||
|
||||
@ -187,20 +210,22 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
|
||||
HttpResponseException exception = assertThrows(HttpResponseException.class, () ->
|
||||
updateAndCheckService(id, update, OK, authHeaders("test@open-metadata.org")));
|
||||
TestUtils.assertResponse(exception, FORBIDDEN, "Principal: CatalogPrincipal{name='test'} is not admin");
|
||||
TestUtils.assertResponse(exception, FORBIDDEN, "Principal: CatalogPrincipal{name='test'} " +
|
||||
"is not admin");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void get_nonExistentTeam_404_notFound() {
|
||||
HttpResponseException exception = assertThrows(HttpResponseException.class, () ->
|
||||
getService(TestUtils.NON_EXISTENT_ENTITY, adminAuthHeaders()));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND, CatalogExceptionMessage.entityNotFound(Entity.DATABASE_SERVICE, TestUtils.NON_EXISTENT_ENTITY));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND, CatalogExceptionMessage.entityNotFound(Entity.DATABASE_SERVICE,
|
||||
TestUtils.NON_EXISTENT_ENTITY));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void get_nonExistentTeamByName_404_notFound() {
|
||||
HttpResponseException exception = assertThrows(HttpResponseException.class, ()
|
||||
-> getServiceByName("invalidName",null, adminAuthHeaders()));
|
||||
-> getServiceByName("invalidName", null, adminAuthHeaders()));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND, CatalogExceptionMessage.entityNotFound(Entity.DATABASE_SERVICE,
|
||||
"invalidName"));
|
||||
}
|
||||
@ -208,15 +233,18 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
public static DatabaseService createAndCheckService(CreateDatabaseService create,
|
||||
Map<String, String> authHeaders) throws HttpResponseException {
|
||||
DatabaseService service = createService(create, authHeaders);
|
||||
validateService(service, create.getName(), create.getDescription(), create.getJdbc(), create.getIngestionSchedule());
|
||||
validateService(service, create.getName(), create.getDescription(), create.getJdbc(),
|
||||
create.getIngestionSchedule());
|
||||
|
||||
// GET the newly created service and validate
|
||||
DatabaseService getService = getService(service.getId(), authHeaders);
|
||||
validateService(getService, create.getName(), create.getDescription(), create.getJdbc(), create.getIngestionSchedule());
|
||||
validateService(getService, create.getName(), create.getDescription(), create.getJdbc(),
|
||||
create.getIngestionSchedule());
|
||||
|
||||
// GET the newly created service by name and validate
|
||||
getService = getServiceByName(service.getName(), null, authHeaders);
|
||||
validateService(getService, create.getName(), create.getDescription(), create.getJdbc(), create.getIngestionSchedule());
|
||||
validateService(getService, create.getName(), create.getDescription(), create.getJdbc(),
|
||||
create.getIngestionSchedule());
|
||||
return service;
|
||||
}
|
||||
|
||||
@ -246,13 +274,15 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
return getService(id, null, authHeaders);
|
||||
}
|
||||
|
||||
public static DatabaseService getService(UUID id, String fields, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
public static DatabaseService getService(UUID id, String fields, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
WebTarget target = CatalogApplicationTest.getResource("services/databaseServices/" + id);
|
||||
target = fields != null ? target.queryParam("fields", fields) : target;
|
||||
return TestUtils.get(target, DatabaseService.class, authHeaders);
|
||||
}
|
||||
|
||||
public static DatabaseService getServiceByName(String name, String fields, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
public static DatabaseService getServiceByName(String name, String fields, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
WebTarget target = CatalogApplicationTest.getResource("services/databaseServices/name/" + name);
|
||||
target = fields != null ? target.queryParam("fields", fields) : target;
|
||||
return TestUtils.get(target, DatabaseService.class, authHeaders);
|
||||
@ -278,15 +308,18 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
Map<String, String> authHeaders = adminAuthHeaders();
|
||||
DatabaseService databaseService = createService(create(test), authHeaders);
|
||||
HttpResponseException exception = assertThrows(HttpResponseException.class, () ->
|
||||
deleteService(databaseService.getId(), databaseService.getName(), authHeaders("test@open-metadata.org")));
|
||||
TestUtils.assertResponse(exception, FORBIDDEN, "Principal: CatalogPrincipal{name='test'} is not admin");
|
||||
deleteService(databaseService.getId(), databaseService.getName(),
|
||||
authHeaders("test@open-metadata.org")));
|
||||
TestUtils.assertResponse(exception, FORBIDDEN,
|
||||
"Principal: CatalogPrincipal{name='test'} is not admin");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void delete_notExistentDatabaseService() {
|
||||
HttpResponseException exception = assertThrows(HttpResponseException.class, () ->
|
||||
getService(TestUtils.NON_EXISTENT_ENTITY, adminAuthHeaders()));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND, CatalogExceptionMessage.entityNotFound(Entity.DATABASE_SERVICE, TestUtils.NON_EXISTENT_ENTITY));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND,
|
||||
CatalogExceptionMessage.entityNotFound(Entity.DATABASE_SERVICE, TestUtils.NON_EXISTENT_ENTITY));
|
||||
}
|
||||
|
||||
private void deleteService(UUID id, String name, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
@ -298,13 +331,15 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// Ensure deleted service does not exist when getting by name
|
||||
exception = assertThrows(HttpResponseException.class, () -> getServiceByName(name, null, authHeaders));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND, CatalogExceptionMessage.entityNotFound(Entity.DATABASE_SERVICE, name));
|
||||
TestUtils.assertResponse(exception, NOT_FOUND,
|
||||
CatalogExceptionMessage.entityNotFound(Entity.DATABASE_SERVICE, name));
|
||||
}
|
||||
|
||||
public static CreateDatabaseService create(TestInfo test) {
|
||||
String startDate = RestUtil.DATE_TIME_FORMAT.format(new Date());
|
||||
return new CreateDatabaseService().withName(getName(test)).withServiceType(DatabaseServiceType.Snowflake)
|
||||
.withJdbc(TestUtils.JDBC_INFO).withIngestionSchedule(new Schedule().withStartDate(startDate).withRepeatFrequency("P1D"));
|
||||
.withJdbc(TestUtils.JDBC_INFO)
|
||||
.withIngestionSchedule(new Schedule().withStartDate(startDate).withRepeatFrequency("P1D"));
|
||||
}
|
||||
|
||||
private static CreateDatabaseService create(TestInfo test, int index) {
|
||||
@ -330,7 +365,8 @@ public class DatabaseServiceResourceTest extends CatalogApplicationTest {
|
||||
}
|
||||
|
||||
public static DatabaseService updateDatabaseService(String id, UpdateDatabaseService updated,
|
||||
Status status, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
Status status, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
return TestUtils.put(CatalogApplicationTest.getResource("services/databaseServices/" + id), updated,
|
||||
DatabaseService.class, status, authHeaders);
|
||||
}
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.tags;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@ -266,7 +282,8 @@ public class TagResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// Secondar tag with missing description
|
||||
exception = assertThrows(HttpResponseException.class, ()
|
||||
-> updateSecondaryTag("User", "Address", "Secondary", create, adminAuthHeaders()));
|
||||
-> updateSecondaryTag("User", "Address", "Secondary",
|
||||
create, adminAuthHeaders()));
|
||||
TestUtils.assertResponseContains(exception, BAD_REQUEST, "description must not be null");
|
||||
|
||||
// Long primary tag name
|
||||
@ -277,7 +294,8 @@ public class TagResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// Long secondary tag name
|
||||
exception = assertThrows(HttpResponseException.class, ()
|
||||
-> updateSecondaryTag("User", "Address", "Secondary", create, adminAuthHeaders()));
|
||||
-> updateSecondaryTag("User", "Address", "Secondary",
|
||||
create, adminAuthHeaders()));
|
||||
TestUtils.assertResponseContains(exception, BAD_REQUEST, "name size must be between 2 and 25");
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.teams;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@ -245,7 +261,7 @@ public class TeamResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// We have now reached the last page - test backward scroll till the beginning
|
||||
pageCount = 0;
|
||||
indexInAllTables = totalRecords - limit - forwardPage.getData().size() ;
|
||||
indexInAllTables = totalRecords - limit - forwardPage.getData().size();
|
||||
do {
|
||||
LOG.info("Limit {} backward scrollCount {} beforeCursor {}", limit, pageCount, before);
|
||||
forwardPage = listTeams(null, limit, before, null, adminAuthHeaders());
|
||||
@ -402,7 +418,8 @@ public class TeamResourceTest extends CatalogApplicationTest {
|
||||
// // User patch to add team to user relationship to an invalid user
|
||||
// List<UUID> users = Collections.singletonList(UUID.randomUUID() /* invalid userId */);
|
||||
// UpdateTeam update = new UpdateTeam().withUsers(users);
|
||||
// HttpResponseException exception = assertThrows(HttpResponseException.class, () -> updateTeam(team.getId(), update));
|
||||
// HttpResponseException exception = assertThrows(HttpResponseException.class, () ->
|
||||
// updateTeam(team.getId(), update));
|
||||
// assertEquals(Response.Status.NOT_FOUND.getStatusCode(), exception.getStatusCode());
|
||||
// }
|
||||
|
||||
@ -499,7 +516,8 @@ public class TeamResourceTest extends CatalogApplicationTest {
|
||||
throws JsonProcessingException, HttpResponseException {
|
||||
String updatedJson = JsonUtils.pojoToJson(updated);
|
||||
JsonPatch patch = JsonSchemaUtil.getJsonPatch(originalJson, updatedJson);
|
||||
return TestUtils.patch(CatalogApplicationTest.getResource("teams/" + teamId), patch, Team.class, authHeaders);
|
||||
return TestUtils.patch(CatalogApplicationTest.getResource("teams/" + teamId), patch,
|
||||
Team.class, authHeaders);
|
||||
}
|
||||
private Team patchTeam(String originalJson, Team updated, Map<String, String> authHeaders)
|
||||
throws JsonProcessingException, HttpResponseException {
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.teams;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@ -295,7 +311,7 @@ public class UserResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// We have now reached the last page - test backward scroll till the beginning
|
||||
pageCount = 0;
|
||||
indexInAllTables = totalRecords - limit - forwardPage.getData().size() ;
|
||||
indexInAllTables = totalRecords - limit - forwardPage.getData().size();
|
||||
do {
|
||||
LOG.info("Limit {} backward scrollCount {} beforeCursor {}", limit, pageCount, before);
|
||||
forwardPage = listUsers(null, limit, before, null, adminAuthHeaders());
|
||||
@ -347,7 +363,8 @@ public class UserResourceTest extends CatalogApplicationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patch_userNameChange_as_same_user_200_ok(TestInfo test) throws HttpResponseException, JsonProcessingException {
|
||||
public void patch_userNameChange_as_same_user_200_ok(TestInfo test) throws HttpResponseException,
|
||||
JsonProcessingException {
|
||||
// Ensure user name can't be changed using patch
|
||||
User user = createUser(create(test, 6).withName("test").withDisplayName("displayName")
|
||||
.withEmail("test@email.com"), authHeaders("test@email.com"));
|
||||
@ -475,7 +492,7 @@ public class UserResourceTest extends CatalogApplicationTest {
|
||||
return TestUtils.patch(CatalogApplicationTest.getResource("users/" + userId), patch, User.class, headers);
|
||||
}
|
||||
|
||||
private User patchUser(String originalJson, User updated,Map<String, String> headers)
|
||||
private User patchUser(String originalJson, User updated, Map<String, String> headers)
|
||||
throws JsonProcessingException, HttpResponseException {
|
||||
return patchUser(updated.getId(), originalJson, updated, headers);
|
||||
}
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.resources.usage;
|
||||
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
@ -131,7 +147,7 @@ public class UsageResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// Report usage
|
||||
int weeklyCount = Math.min(day + 1, 7) * usageCount; // Expected cumulative weekly count
|
||||
int monthlyCount = Math.min(day + 1, 30 ) * usageCount; // Expected cumulative monthly count
|
||||
int monthlyCount = Math.min(day + 1, 30) * usageCount; // Expected cumulative monthly count
|
||||
reportUsageAndCheck(TABLE, id, usageReport, weeklyCount, monthlyCount, adminAuthHeaders());
|
||||
|
||||
// Database has cumulative count of all the table usage
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.util;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@ -39,6 +55,7 @@ public class RestUtilTest {
|
||||
List<String> relationships = RestUtil.getRelationships(entity.getClass());
|
||||
List<String> expectedRelationships = Arrays.asList("relationship1", "relationship2");
|
||||
assertEquals(expectedRelationships.size(), relationships.size());
|
||||
assertTrue(relationships.containsAll(expectedRelationships) && expectedRelationships.containsAll(relationships));
|
||||
assertTrue(relationships.containsAll(expectedRelationships) &&
|
||||
expectedRelationships.containsAll(relationships));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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.openmetadata.catalog.util;
|
||||
|
||||
import org.openmetadata.catalog.security.CatalogOpenIdAuthorizationRequestFilter;
|
||||
@ -28,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class TestUtils {
|
||||
public final class TestUtils {
|
||||
// Entity name length allowed is 64 characters. This is a 65 char length invalid entity name
|
||||
public static final String LONG_ENTITY_NAME = "012345678901234567890123456789012345678901234567890123456789012345";
|
||||
public static final UUID NON_EXISTENT_ENTITY = UUID.randomUUID();
|
||||
@ -42,6 +58,9 @@ public class TestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private TestUtils() {
|
||||
}
|
||||
|
||||
public static Builder addHeaders(WebTarget target, Map<String, String> headers) {
|
||||
if (headers != null) {
|
||||
return target.request().header(CatalogOpenIdAuthorizationRequestFilter.X_AUTH_PARAMS_EMAIL_HEADER,
|
||||
@ -118,13 +137,16 @@ public class TestUtils {
|
||||
|
||||
public static <K> void put(WebTarget target, K request, Status expectedStatus, Map<String, String> headers)
|
||||
throws HttpResponseException {
|
||||
Response response = addHeaders(target, headers).method("PUT", Entity.entity(request, MediaType.APPLICATION_JSON));
|
||||
Response response = addHeaders(target, headers).method("PUT", Entity.entity(request,
|
||||
MediaType.APPLICATION_JSON));
|
||||
readResponse(response, expectedStatus.getStatusCode());
|
||||
}
|
||||
|
||||
public static <T, K> T put(WebTarget target, K request, Class<T> clz, Status expectedStatus, Map<String, String> headers)
|
||||
public static <T, K> T put(WebTarget target, K request, Class<T> clz, Status expectedStatus,
|
||||
Map<String, String> headers)
|
||||
throws HttpResponseException {
|
||||
Response response = addHeaders(target, headers).method("PUT", Entity.entity(request, MediaType.APPLICATION_JSON));
|
||||
Response response = addHeaders(target, headers).method("PUT", Entity.entity(request,
|
||||
MediaType.APPLICATION_JSON));
|
||||
return readResponse(response, clz, expectedStatus.getStatusCode());
|
||||
}
|
||||
|
||||
|
||||
@ -15,10 +15,9 @@
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
|
||||
@ -98,11 +97,14 @@
|
||||
<module name="ConstantName"/>
|
||||
<module name="LocalFinalVariableName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
<module name="MemberName"/>
|
||||
<module name="MethodName"/>
|
||||
<!-- <module name="MemberName"/> -->
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName"/>
|
||||
<module name="StaticVariableName"/>
|
||||
<module name="TypeName"/>
|
||||
|
||||
|
||||
@ -191,7 +193,7 @@
|
||||
<module name="FinalClass"/>
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
<module name="VisibilityModifier"/>
|
||||
<!-- <module name="VisibilityModifier"/> -->
|
||||
|
||||
|
||||
<!-- Miscellaneous other checks. -->
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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.openmetadata.common.utils;
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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.openmetadata.common.utils;
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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.openmetadata.common.utils;
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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.openmetadata.common.module;
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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.openmetadata.common.utils;
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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.openmetadata.common.utils;
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
* 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.openmetadata.common.utils;
|
||||
@ -53,7 +52,8 @@ public class JsonSchemaTest {
|
||||
urnFactory = JsonSchemaUtil.getUrnFactory();
|
||||
}
|
||||
|
||||
private java.util.Set<com.networknt.schema.ValidationMessage> validate(InputStream in, String jsonPayload) throws IOException {
|
||||
private java.util.Set<com.networknt.schema.ValidationMessage> validate(InputStream in, String jsonPayload)
|
||||
throws IOException {
|
||||
System.out.println("Validating " + jsonPayload);
|
||||
Set<ValidationMessage> errors = JsonSchemaUtil.validate(in, jsonPayload, urnFactory);
|
||||
System.out.println("Errors " + errors);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user