-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix(knowledge): carry the requested entityStatus onto the created page #31728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Vishnuujain
wants to merge
6
commits into
main
Choose a base branch
from
fix/knowledge-page-entity-status
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+78
−1
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7da9a93
fix(knowledge): carry the requested entityStatus onto the created page
Vishnuujain c83f3d2
test(knowledge): cover an omitted entityStatus, not just an explicit …
Vishnuujain 274c992
Merge branch 'main' into fix/knowledge-page-entity-status
Vishnuujain e6bfc8b
test(knowledge): assert entityStatus propagation instead of the gener…
Vishnuujain 0922200
Merge branch 'main' into fix/knowledge-page-entity-status
Vishnuujain 079a83b
Merge branch 'main' into fix/knowledge-page-entity-status
Vishnuujain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...e/src/test/java/org/openmetadata/service/resources/knowledge/KnowledgePageMapperTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package org.openmetadata.service.resources.knowledge; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.openmetadata.schema.api.data.CreatePage; | ||
| import org.openmetadata.schema.entity.data.Article; | ||
| import org.openmetadata.schema.entity.data.Page; | ||
| import org.openmetadata.schema.entity.data.PageType; | ||
| import org.openmetadata.schema.type.EntityReference; | ||
| import org.openmetadata.schema.type.EntityStatus; | ||
|
|
||
| class KnowledgePageMapperTest { | ||
|
|
||
| @Test | ||
| void theRequestedEntityStatusReachesTheEntity() { | ||
| // CreatePage carries entityStatus, but the mapper never copied it, so every article was | ||
| // persisted as Unprocessed no matter what the caller asked for. | ||
| Page page = | ||
| new KnowledgePageMapper().createToEntity(createPage(EntityStatus.ARCHIVED), "admin"); | ||
|
|
||
| assertEquals(EntityStatus.ARCHIVED, page.getEntityStatus()); | ||
| } | ||
|
|
||
| @Test | ||
| void anOmittedEntityStatusIsCarriedThroughUnchanged() { | ||
| // Omits entityStatus entirely instead of setting it to null. Asserts propagation rather than a | ||
| // literal value on purpose: createPage.json declares "default": "Approved" next to a $ref, and | ||
| // whether jsonschema2pojo materializes that default at all depends on schema processing order, | ||
| // so the generated field is null on some builds and Unprocessed on others. Either way the | ||
| // mapper must hand the value through untouched - null then reaches | ||
| // EntityRepository.setDefaultStatus, which fills in Unprocessed. | ||
| CreatePage request = | ||
| withRelatedEntity( | ||
| new CreatePage() | ||
| .withName("runbook") | ||
| .withPageType(PageType.ARTICLE) | ||
| .withPage(new Article())); | ||
|
|
||
| Page page = new KnowledgePageMapper().createToEntity(request, "admin"); | ||
|
|
||
| assertEquals(request.getEntityStatus(), page.getEntityStatus()); | ||
| } | ||
|
|
||
| @Test | ||
| void anExplicitNullEntityStatusIsLeftForTheRepositoryDefault() { | ||
| // The mapper must not invent a status of its own: a null reaches the repository, which then | ||
| // fills in Unprocessed via setDefaultStatus. | ||
| Page page = new KnowledgePageMapper().createToEntity(createPage(null), "admin"); | ||
|
|
||
| assertNull(page.getEntityStatus()); | ||
| } | ||
|
|
||
| private static CreatePage createPage(EntityStatus status) { | ||
| return withRelatedEntity( | ||
| new CreatePage() | ||
| .withName("runbook") | ||
| .withPageType(PageType.ARTICLE) | ||
| .withPage(new Article())) | ||
| .withEntityStatus(status); | ||
| } | ||
|
|
||
| /** | ||
| * Supplies relatedEntities so the mapper skips its Organization-team fallback, which needs a live | ||
| * entity registry and is not what these tests are about. | ||
| */ | ||
| private static CreatePage withRelatedEntity(CreatePage request) { | ||
| return request.withRelatedEntities( | ||
| List.of(new EntityReference().withId(UUID.randomUUID()).withType("table"))); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.