mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 18:48:35 +00:00 
			
		
		
		
	MINOR: Updated test case name field (#16048)
* Removed entityName char limit * updated new field * fixed backend tests * fixed linting
This commit is contained in:
		
							parent
							
								
									a0db32c18a
								
							
						
					
					
						commit
						3d2e2e8214
					
				| @ -48,6 +48,8 @@ import org.junit.jupiter.api.Order; | |||||||
| import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; | ||||||
| import org.junit.jupiter.api.TestInfo; | import org.junit.jupiter.api.TestInfo; | ||||||
| import org.junit.jupiter.api.TestMethodOrder; | 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.data.CreateTable; | ||||||
| import org.openmetadata.schema.api.feed.CloseTask; | import org.openmetadata.schema.api.feed.CloseTask; | ||||||
| import org.openmetadata.schema.api.feed.ResolveTask; | import org.openmetadata.schema.api.feed.ResolveTask; | ||||||
| @ -2376,6 +2378,28 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes | |||||||
|     assertEquals(updated.getInspectionQuery(), inspectionQuery); |     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) |   private void putInspectionQuery(TestCase testCase, String sql, Map<String, String> authHeaders) | ||||||
|       throws IOException { |       throws IOException { | ||||||
|     TestCase putResponse = putInspectionQuery(testCase.getId(), sql, authHeaders); |     TestCase putResponse = putInspectionQuery(testCase.getId(), sql, authHeaders); | ||||||
|  | |||||||
| @ -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.assertListNotNull; | ||||||
| import static org.openmetadata.service.util.TestUtils.assertListNull; | import static org.openmetadata.service.util.TestUtils.assertListNull; | ||||||
| import static org.openmetadata.service.util.TestUtils.assertResponse; | import static org.openmetadata.service.util.TestUtils.assertResponse; | ||||||
|  | import static org.openmetadata.service.util.TestUtils.assertResponseContains; | ||||||
| 
 | 
 | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.util.List; | 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.Assertions; | ||||||
| import org.junit.jupiter.api.Test; | import org.junit.jupiter.api.Test; | ||||||
| import org.junit.jupiter.api.TestInfo; | 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.api.tests.CreateTestDefinition; | ||||||
| import org.openmetadata.schema.tests.TestCaseParameter; | import org.openmetadata.schema.tests.TestCaseParameter; | ||||||
| import org.openmetadata.schema.tests.TestDefinition; | 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.Entity; | ||||||
| import org.openmetadata.service.resources.EntityResourceTest; | import org.openmetadata.service.resources.EntityResourceTest; | ||||||
| import org.openmetadata.service.util.ResultList; | import org.openmetadata.service.util.ResultList; | ||||||
|  | import org.openmetadata.service.util.TestUtils; | ||||||
| 
 | 
 | ||||||
| public class TestDefinitionResourceTest | public class TestDefinitionResourceTest | ||||||
|     extends EntityResourceTest<TestDefinition, CreateTestDefinition> { |     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 |   @Override | ||||||
|   public CreateTestDefinition createRequest(String name) { |   public CreateTestDefinition createRequest(String name) { | ||||||
|     return new CreateTestDefinition() |     return new CreateTestDefinition() | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ | |||||||
|   "properties": { |   "properties": { | ||||||
|     "name": { |     "name": { | ||||||
|       "description": "Name that identifies this test case.", |       "description": "Name that identifies this test case.", | ||||||
|       "$ref": "../../type/basic.json#/definitions/entityName" |       "$ref": "../../type/basic.json#/definitions/testCaseEntityName" | ||||||
|     }, |     }, | ||||||
|     "description": { |     "description": { | ||||||
|       "description": "Description of the testcase.", |       "description": "Description of the testcase.", | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ | |||||||
|   "properties": { |   "properties": { | ||||||
|     "name": { |     "name": { | ||||||
|       "description": "Name that identifies this test case.", |       "description": "Name that identifies this test case.", | ||||||
|       "$ref": "../../type/basic.json#/definitions/entityName" |       "$ref": "../../type/basic.json#/definitions/testCaseEntityName" | ||||||
|     }, |     }, | ||||||
|     "displayName": { |     "displayName": { | ||||||
|       "description": "Display Name that identifies this test case.", |       "description": "Display Name that identifies this test case.", | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ | |||||||
|     }, |     }, | ||||||
|     "name": { |     "name": { | ||||||
|       "description": "Name that identifies this test case.", |       "description": "Name that identifies this test case.", | ||||||
|       "$ref": "../type/basic.json#/definitions/entityName" |       "$ref": "../type/basic.json#/definitions/testCaseEntityName" | ||||||
|     }, |     }, | ||||||
|     "displayName": { |     "displayName": { | ||||||
|       "description": "Display Name that identifies this test.", |       "description": "Display Name that identifies this test.", | ||||||
|  | |||||||
| @ -113,7 +113,7 @@ | |||||||
|     }, |     }, | ||||||
|     "name": { |     "name": { | ||||||
|       "description": "Name that identifies this test case.", |       "description": "Name that identifies this test case.", | ||||||
|       "$ref": "../type/basic.json#/definitions/entityName" |       "$ref": "../type/basic.json#/definitions/testCaseEntityName" | ||||||
|     }, |     }, | ||||||
|     "displayName": { |     "displayName": { | ||||||
|       "description": "Display Name that identifies this test case.", |       "description": "Display Name that identifies this test case.", | ||||||
|  | |||||||
| @ -110,6 +110,12 @@ | |||||||
|       "maxLength": 256, |       "maxLength": 256, | ||||||
|       "pattern": "^((?!::).)*$" |       "pattern": "^((?!::).)*$" | ||||||
|     }, |     }, | ||||||
|  |     "testCaseEntityName": { | ||||||
|  |       "description": "Name that identifies a test definition and test case.", | ||||||
|  |       "type": "string", | ||||||
|  |       "minLength": 1, | ||||||
|  |       "pattern": "^((?!::).)*$" | ||||||
|  |     }, | ||||||
|     "fullyQualifiedEntityName": { |     "fullyQualifiedEntityName": { | ||||||
|       "description": "A unique name that identifies an entity. Example for table 'DatabaseService.Database.Schema.Table'.", |       "description": "A unique name that identifies an entity. Example for table 'DatabaseService.Database.Schema.Table'.", | ||||||
|       "type": "string", |       "type": "string", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Onkar Ravgan
						Onkar Ravgan