MINOR: Updated test case name field (#16048)

* Removed entityName char limit

* updated new field

* fixed backend tests

* fixed linting
This commit is contained in:
Onkar Ravgan 2024-05-03 13:49:44 +05:30 committed by GitHub
parent a0db32c18a
commit 3d2e2e8214
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 60 additions and 4 deletions

View File

@ -48,6 +48,8 @@ import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.openmetadata.schema.api.data.CreateTable;
import org.openmetadata.schema.api.feed.CloseTask;
import org.openmetadata.schema.api.feed.ResolveTask;
@ -2376,6 +2378,28 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
assertEquals(updated.getInspectionQuery(), inspectionQuery);
}
@Test
@Execution(ExecutionMode.CONCURRENT)
protected void post_entityCreateWithInvalidName_400() {
// Create an entity with mandatory name field null
final CreateTestCase request = createRequest(null, "description", "displayName", null);
assertResponseContains(
() -> createEntity(request, ADMIN_AUTH_HEADERS), BAD_REQUEST, "[name must not be null]");
// Create an entity with mandatory name field empty
final CreateTestCase request1 = createRequest("", "description", "displayName", null);
assertResponseContains(
() -> createEntity(request1, ADMIN_AUTH_HEADERS),
BAD_REQUEST,
TestUtils.getEntityNameLengthError(entityClass));
// Any entity name that has EntityLink separator must fail
final CreateTestCase request3 =
createRequest("invalid::Name", "description", "displayName", null);
assertResponseContains(
() -> createEntity(request3, ADMIN_AUTH_HEADERS), BAD_REQUEST, "name must match");
}
private void putInspectionQuery(TestCase testCase, String sql, Map<String, String> authHeaders)
throws IOException {
TestCase putResponse = putInspectionQuery(testCase.getId(), sql, authHeaders);

View File

@ -6,6 +6,7 @@ import static org.openmetadata.service.util.TestUtils.ADMIN_AUTH_HEADERS;
import static org.openmetadata.service.util.TestUtils.assertListNotNull;
import static org.openmetadata.service.util.TestUtils.assertListNull;
import static org.openmetadata.service.util.TestUtils.assertResponse;
import static org.openmetadata.service.util.TestUtils.assertResponseContains;
import java.io.IOException;
import java.util.List;
@ -14,6 +15,8 @@ import org.apache.http.client.HttpResponseException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.openmetadata.schema.api.tests.CreateTestDefinition;
import org.openmetadata.schema.tests.TestCaseParameter;
import org.openmetadata.schema.tests.TestDefinition;
@ -22,6 +25,7 @@ import org.openmetadata.schema.type.TestDefinitionEntityType;
import org.openmetadata.service.Entity;
import org.openmetadata.service.resources.EntityResourceTest;
import org.openmetadata.service.util.ResultList;
import org.openmetadata.service.util.TestUtils;
public class TestDefinitionResourceTest
extends EntityResourceTest<TestDefinition, CreateTestDefinition> {
@ -89,6 +93,28 @@ public class TestDefinitionResourceTest
}
}
@Test
@Execution(ExecutionMode.CONCURRENT)
protected void post_entityCreateWithInvalidName_400() {
// Create an entity with mandatory name field null
final CreateTestDefinition request = createRequest(null, "description", "displayName", null);
assertResponseContains(
() -> createEntity(request, ADMIN_AUTH_HEADERS), BAD_REQUEST, "[name must not be null]");
// Create an entity with mandatory name field empty
final CreateTestDefinition request1 = createRequest("", "description", "displayName", null);
assertResponseContains(
() -> createEntity(request1, ADMIN_AUTH_HEADERS),
BAD_REQUEST,
TestUtils.getEntityNameLengthError(entityClass));
// Any entity name that has EntityLink separator must fail
final CreateTestDefinition request3 =
createRequest("invalid::Name", "description", "displayName", null);
assertResponseContains(
() -> createEntity(request3, ADMIN_AUTH_HEADERS), BAD_REQUEST, "name must match");
}
@Override
public CreateTestDefinition createRequest(String name) {
return new CreateTestDefinition()

View File

@ -9,7 +9,7 @@
"properties": {
"name": {
"description": "Name that identifies this test case.",
"$ref": "../../type/basic.json#/definitions/entityName"
"$ref": "../../type/basic.json#/definitions/testCaseEntityName"
},
"description": {
"description": "Description of the testcase.",

View File

@ -9,7 +9,7 @@
"properties": {
"name": {
"description": "Name that identifies this test case.",
"$ref": "../../type/basic.json#/definitions/entityName"
"$ref": "../../type/basic.json#/definitions/testCaseEntityName"
},
"displayName": {
"description": "Display Name that identifies this test case.",

View File

@ -30,7 +30,7 @@
},
"name": {
"description": "Name that identifies this test case.",
"$ref": "../type/basic.json#/definitions/entityName"
"$ref": "../type/basic.json#/definitions/testCaseEntityName"
},
"displayName": {
"description": "Display Name that identifies this test.",

View File

@ -113,7 +113,7 @@
},
"name": {
"description": "Name that identifies this test case.",
"$ref": "../type/basic.json#/definitions/entityName"
"$ref": "../type/basic.json#/definitions/testCaseEntityName"
},
"displayName": {
"description": "Display Name that identifies this test case.",

View File

@ -110,6 +110,12 @@
"maxLength": 256,
"pattern": "^((?!::).)*$"
},
"testCaseEntityName": {
"description": "Name that identifies a test definition and test case.",
"type": "string",
"minLength": 1,
"pattern": "^((?!::).)*$"
},
"fullyQualifiedEntityName": {
"description": "A unique name that identifies an entity. Example for table 'DatabaseService.Database.Schema.Table'.",
"type": "string",