Commit db6d783a by apoorvnaik

ATLAS-2596: Missing classification mapping for GlossaryTerm

Change-Id: I9f1e28601f37093686e0d9d236b87c4a03a9c512
parent fe1c7a3b
...@@ -168,6 +168,13 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm> ...@@ -168,6 +168,13 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm>
ret.setValidValuesFor(toRelatedTermIdsSet(validValuesFor)); ret.setValidValuesFor(toRelatedTermIdsSet(validValuesFor));
} }
if (CollectionUtils.isNotEmpty(entity.getClassifications())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Processing term classifications");
}
ret.setClassifications(entity.getClassifications());
}
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasGlossaryTermDTO.from() : {}", ret); LOG.debug("<== AtlasGlossaryTermDTO.from() : {}", ret);
} }
...@@ -206,6 +213,13 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm> ...@@ -206,6 +213,13 @@ public class AtlasGlossaryTermDTO extends AbstractGlossaryDTO<AtlasGlossaryTerm>
ret.setAttribute("examples", obj.getExamples()); ret.setAttribute("examples", obj.getExamples());
ret.setAttribute("abbreviation", obj.getAbbreviation()); ret.setAttribute("abbreviation", obj.getAbbreviation());
if (CollectionUtils.isNotEmpty(obj.getClassifications())) {
if (LOG.isDebugEnabled()) {
LOG.debug("Processing term classifications");
}
ret.setClassifications(obj.getClassifications());
}
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasGlossaryTermDTO.toEntity() : {}", ret); LOG.debug("<== AtlasGlossaryTermDTO.toEntity() : {}", ret);
} }
......
...@@ -29,10 +29,13 @@ import org.apache.atlas.model.glossary.relations.AtlasGlossaryHeader; ...@@ -29,10 +29,13 @@ import org.apache.atlas.model.glossary.relations.AtlasGlossaryHeader;
import org.apache.atlas.model.glossary.relations.AtlasRelatedCategoryHeader; import org.apache.atlas.model.glossary.relations.AtlasRelatedCategoryHeader;
import org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader; import org.apache.atlas.model.glossary.relations.AtlasRelatedTermHeader;
import org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader; import org.apache.atlas.model.glossary.relations.AtlasTermCategorizationHeader;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasEntityHeader; import org.apache.atlas.model.instance.AtlasEntityHeader;
import org.apache.atlas.model.instance.AtlasRelatedObjectId; import org.apache.atlas.model.instance.AtlasRelatedObjectId;
import org.apache.atlas.model.instance.EntityMutationResponse; import org.apache.atlas.model.instance.EntityMutationResponse;
import org.apache.atlas.model.typedef.AtlasClassificationDef;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.repository.impexp.ZipFileResourceTestUtils; import org.apache.atlas.repository.impexp.ZipFileResourceTestUtils;
import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.AtlasEntityStore;
import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream; import org.apache.atlas.repository.store.graph.v1.AtlasEntityStream;
...@@ -95,6 +98,15 @@ public class GlossaryServiceTest { ...@@ -95,6 +98,15 @@ public class GlossaryServiceTest {
throw new SkipException("SubjectArea model loading failed"); throw new SkipException("SubjectArea model loading failed");
} }
try {
AtlasClassificationDef classificationDef = new AtlasClassificationDef("TestClassification", "Test only classification");
AtlasTypesDef typesDef = new AtlasTypesDef();
typesDef.setClassificationDefs(Arrays.asList(classificationDef));
typeDefStore.createTypesDef(typesDef);
} catch (AtlasBaseException e) {
throw new SkipException("Test classification creation failed");
}
// Glossary // Glossary
bankGlossary = new AtlasGlossary(); bankGlossary = new AtlasGlossary();
bankGlossary.setQualifiedName("testBankingGlossary"); bankGlossary.setQualifiedName("testBankingGlossary");
...@@ -342,6 +354,7 @@ public class GlossaryServiceTest { ...@@ -342,6 +354,7 @@ public class GlossaryServiceTest {
@Test(groups = "Glossary.UPDATE", dependsOnGroups = "Glossary.CREATE") @Test(groups = "Glossary.UPDATE", dependsOnGroups = "Glossary.CREATE")
public void testUpdateGlossaryTerm() { public void testUpdateGlossaryTerm() {
List<AtlasGlossaryTerm> glossaryTerms = new ArrayList<>(); List<AtlasGlossaryTerm> glossaryTerms = new ArrayList<>();
AtlasClassification classification = new AtlasClassification("TestClassification");
for (AtlasGlossaryTerm term : Arrays.asList(checkingAccount, savingsAccount, fixedRateMortgage, adjustableRateMortgage)) { for (AtlasGlossaryTerm term : Arrays.asList(checkingAccount, savingsAccount, fixedRateMortgage, adjustableRateMortgage)) {
try { try {
glossaryTerms.add(glossaryService.getTerm(term.getGuid())); glossaryTerms.add(glossaryService.getTerm(term.getGuid()));
...@@ -354,9 +367,13 @@ public class GlossaryServiceTest { ...@@ -354,9 +367,13 @@ public class GlossaryServiceTest {
t.setShortDescription("Updated short description"); t.setShortDescription("Updated short description");
t.setLongDescription("Updated long description"); t.setLongDescription("Updated long description");
entityStore.addClassifications(t.getGuid(), Arrays.asList(classification));
AtlasGlossaryTerm updatedTerm = glossaryService.updateTerm(t); AtlasGlossaryTerm updatedTerm = glossaryService.updateTerm(t);
assertNotNull(updatedTerm); assertNotNull(updatedTerm);
assertEquals(updatedTerm.getGuid(), t.getGuid()); assertEquals(updatedTerm.getGuid(), t.getGuid());
assertNotNull(updatedTerm.getClassifications());
assertEquals(updatedTerm.getClassifications().size(), 1);
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
fail("Glossary term fetch/update should've succeeded", e); fail("Glossary term fetch/update should've succeeded", e);
} }
......
...@@ -251,7 +251,6 @@ public class UserProfileServiceTest { ...@@ -251,7 +251,6 @@ public class UserProfileServiceTest {
List<AtlasUserSavedSearch> savedSearchList = userProfileService.getSavedSearches(userName); List<AtlasUserSavedSearch> savedSearchList = userProfileService.getSavedSearches(userName);
assertEquals(savedSearchList.size(), new_max_searches - 1); assertEquals(savedSearchList.size(), new_max_searches - 1);
} }
@Test(dependsOnMethods = {"createsNewProfile", "savesMultipleQueriesForUser", "verifyQueryNameListForUser"}) @Test(dependsOnMethods = {"createsNewProfile", "savesMultipleQueriesForUser", "verifyQueryNameListForUser"})
void deleteUser() throws AtlasBaseException { void deleteUser() throws AtlasBaseException {
String userName = getIndexBasedUserName(1); String userName = getIndexBasedUserName(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment