@Test public void multipleDocsSameFortress() throws Exception { try { logger.debug("### multipleDocsSameFortress"); setSecurity(); engineConfig.setConceptsEnabled(true); Transaction t = beginManualTransaction(); SystemUser su = registerSystemUser("multipleDocsSameFortress", mike_admin); assertNotNull(su); Fortress fortress = fortressService.registerFortress( su.getCompany(), new FortressInputBean("multipleDocsSameFortress", true)); DocumentType dType = conceptService.resolveByDocCode(fortress, "ABC123", true); commitManualTransaction(t); // Should only be only one docTypes assertNotNull(dType); Long id = dType.getId(); dType = conceptService.resolveByDocCode(fortress, "ABC123", false); assertEquals(id, dType.getId()); EntityInputBean input = new EntityInputBean(fortress, "jinks", "DocA", new DateTime()); input.addTag(new TagInputBean("cust123", "Customer", "purchased").setLabel("Customer")); mediationFacade.trackEntity(su.getCompany(), input).getEntity(); validateConcepts("DocA", su, 1); // Different docs, same concepts input = new EntityInputBean(fortress, "jinks", "DocB", new DateTime()); input.addTag(new TagInputBean("cust123", "Customer", "purchased").setLabel("Customer")); mediationFacade.trackEntity(su.getCompany(), input).getEntity(); validateConcepts((Collection<String>) null, su, 3); // 3 Doc types. assertEquals( "Docs In Use not supporting 'null args' for fortress'", 3, conceptService.getDocumentsInUse(su.getCompany()).size()); // DAT-112 Set<DocumentResultBean> found = validateConcepts("DocA", su, 1); assertEquals(1, found.size()); assertEquals(1, found.iterator().next().getConcepts().size()); found = validateConcepts("DocB", su, 1); assertEquals(1, found.size()); // Removed the mock user assertEquals("Didn't find the Document ", 1, found.iterator().next().getConcepts().size()); } finally { cleanUpGraph(); } }
@Test public void multipleRelationships() throws Exception { try { logger.debug("### multipleRelationships"); setSecurity(); engineConfig.setConceptsEnabled(true); Transaction t = beginManualTransaction(); SystemUser su = registerSystemUser("multipleRelationships", mike_admin); assertNotNull(su); Fortress fortress = fortressService.registerFortress( su.getCompany(), new FortressInputBean("multipleRelationships", true)); DocumentType dType = conceptService.resolveByDocCode(fortress, "ABC123", true); commitManualTransaction(t); // Should only be only one docTypes assertNotNull(dType); Long id = dType.getId(); dType = conceptService.resolveByDocCode(fortress, "ABC123", false); assertEquals(id, dType.getId()); EntityInputBean input = new EntityInputBean(fortress, "jinks", "DocA", new DateTime()); input.addTag(new TagInputBean("cust123", "Customer", "purchased").setLabel("Customer")); input.addTag(new TagInputBean("harry", "Customer", "soldto").setLabel("Customer")); mediationFacade.trackEntity(su.getCompany(), input).getEntity(); Set<DocumentResultBean> docResults = conceptService.findConcepts(su.getCompany(), "DocA", true); assertEquals(1, docResults.size()); assertEquals(1, docResults.iterator().next().getConcepts().size()); assertEquals( "should have been two relationships", 2, docResults.iterator().next().getConcepts().iterator().next().getRelationships().size()); input = new EntityInputBean(fortress, "jinks", "DocA", new DateTime()); input.addTag(new TagInputBean("cust121", "Customer", "purchased").setLabel("Customer")); input.addTag(new TagInputBean("harry", "Customer", "soldto").setLabel("Customer")); mediationFacade.trackEntity(su.getCompany(), input).getEntity(); validateConcepts("DocA", su, 1); Collection<String> docs = new ArrayList<>(); docs.add("DocA"); Set<DocumentResultBean> docTypes = conceptService.getConceptsWithRelationships(su.getCompany(), docs); for (DocumentResultBean docType : docTypes) { Collection<ConceptResultBean> concepts = docType.getConcepts(); for (ConceptResultBean concept : concepts) { Collection<RelationshipResultBean> relationships = concept.getRelationships(); for (RelationshipResultBean relationship : relationships) { logger.debug(relationship.getName()); } if (concept.getName().equals("User")) { // Currently only tracking the created. Should be 2 when tracking the updated assertEquals(1, relationships.size()); } else assertEquals(2, relationships.size()); } } assertEquals( "Docs In Use not supporting 'null args'", 2, conceptService.getConceptsWithRelationships(su.getCompany(), null).size()); } finally { cleanUpGraph(); } }
@Test public void relationshipWorkForMultipleDocuments() throws Exception { try { logger.debug("### relationshipWorkForMultipleDocuments"); setSecurity(); engineConfig.setConceptsEnabled(true); engineConfig.setTestMode(true); Transaction t = beginManualTransaction(); SystemUser su = registerSystemUser("relationshipWorkForMultipleDocuments", mike_admin); assertNotNull(su); Fortress fortress = fortressService.registerFortress( su.getCompany(), new FortressInputBean("relationshipWorkForMultipleDocuments", true)); DocumentType docA = conceptService.resolveByDocCode(fortress, "DOCA", true); DocumentType docB = conceptService.resolveByDocCode(fortress, "DOCB", true); commitManualTransaction(t); // Should only be only one docTypes assertNotNull(docA); Long idA = docA.getId(); docA = conceptService.resolveByDocCode(fortress, docA.getName(), false); assertEquals(idA, docA.getId()); EntityInputBean input = new EntityInputBean(fortress, "jinks", "DocA", new DateTime()); input.addTag(new TagInputBean("cust123", "Customer", "purchased").setLabel("Customer")); mediationFacade.trackEntity(su.getCompany(), input).getEntity(); input = new EntityInputBean(fortress, "jinks", docB.getName(), new DateTime()); input.addTag(new TagInputBean("cust121", "Customer", "purchased").setLabel("Customer")); mediationFacade.trackEntity(su.getCompany(), input).getEntity(); Collection<String> docs = new ArrayList<>(); docs.add(docA.getName()); docs.add(docB.getName()); Set<DocumentResultBean> docTypes = conceptService.getConceptsWithRelationships(su.getCompany(), docs); for (DocumentResultBean docType : docTypes) { Collection<ConceptResultBean> concepts = docType.getConcepts(); for (ConceptResultBean concept : concepts) { Collection<RelationshipResultBean> relationships = concept.getRelationships(); TestCase.assertEquals(1, relationships.size()); // for (RelationshipResultBean relationship : relationships) { // assertEquals(1, relationship.getDocumentTypes().size()); // if (docType.getName().equals(docA.getName())) // docAFound = true; // else if (docType.getName().equals(docB.getName())) // docBFound = true; // } } } // ToDo: it is unclear if we should track in this manner // assertTrue("DocA Not Found in the concept", docAFound); // assertTrue("DocB Not Found in the concept", docBFound); assertEquals( "Docs In Use not supporting 'null args'", 2, conceptService.getConceptsWithRelationships(su.getCompany(), null).size()); } finally { cleanUpGraph(); } }
@Test public void fortressConcepts() throws Exception { try { logger.debug("### fortressConcepts"); Transaction t = beginManualTransaction(); setSecurity(); SystemUser su = registerSystemUser("fortressConcepts", mike_admin); assertNotNull(su); engineConfig.setConceptsEnabled(true); engineConfig.setTestMode(true); Fortress fortA = fortressService.registerFortress( su.getCompany(), new FortressInputBean("fortressConcepts", true)); DocumentType dType = conceptService.resolveByDocCode(fortA, "ABC123", true); commitManualTransaction(t); // Should only be only one docTypes assertNotNull(dType); Long id = dType.getId(); dType = conceptService.resolveByDocCode(fortA, "ABC123", false); assertEquals(id, dType.getId()); EntityInputBean input = new EntityInputBean(fortA, "jinks", "DocA", new DateTime()); input.addTag(new TagInputBean("cust123", "Customer", "purchased")); Entity meta = mediationFacade.trackEntity(su.getCompany(), input).getEntity(); assertNotNull(entityService.getEntity(su.getCompany(), meta.getKey())); input = new EntityInputBean(fortA, "jinks", "DocA", new DateTime()); input.addTag(new TagInputBean("cust124", "Customer", "purchased").setLabel("Customer")); mediationFacade.trackEntity(su.getCompany(), input).getEntity(); Collection<String> docs = new ArrayList<>(); docs.add("DocA"); Collection<DocumentResultBean> documentTypes = conceptService.findConcepts(su.getCompany(), docs, false); assertNotNull(documentTypes); assertEquals(1, documentTypes.size()); // add a second docTypes input = new EntityInputBean(fortA, "jinks", "DocA", new DateTime()); input.addTag(new TagInputBean("cust123", "Rep", "sold").setLabel("Rep")); mediationFacade.trackEntity(su.getCompany(), input); documentTypes = conceptService.getConceptsWithRelationships(su.getCompany(), docs); assertEquals("Only one doc type should exist", 1, documentTypes.size()); Boolean foundCustomer = false, foundRep = false; for (DocumentResultBean docTypes : documentTypes) { for (ConceptResultBean concept : docTypes.getConcepts()) { if (concept.getName().equals("Customer")) { foundCustomer = true; assertEquals(1, concept.getRelationships().size()); Assert.assertEquals( "purchased", concept.getRelationships().iterator().next().getName()); assertEquals(true, concept.toString().contains(concept.getName())); } if (concept.getName().equals("Rep")) { foundRep = true; assertEquals(1, concept.getRelationships().size()); Assert.assertEquals("sold", concept.getRelationships().iterator().next().getName()); assertEquals(true, concept.toString().contains(concept.getName())); } } } assertTrue("Didn't find Customer concept", foundCustomer); assertTrue("Didn't find Rep concept", foundRep); } finally { cleanUpGraph(); } }