@Test @SuppressWarnings("unchecked") public void testGetContainerProperty() { TestEntity entity = createTestEntity(); Property<String> containerProperty = (Property<String>) container.getContainerProperty(entity.getId(), TestEntity.TEST_PROPERTY); assertEquals("content", entity.getTestString(), containerProperty.getValue()); }
public void setTestNotNull(TestEntity testNotNull) { if (testNotNull == null) { throw new DaoException( "To-one property 'testIdNotNull' has not-null constraint; cannot set to-one to null"); } this.testNotNull = testNotNull; testIdNotNull = testNotNull.getId(); testNotNull__resolvedKey = testIdNotNull; }
@Test public void testReplaceSimpleSearchable() { TestEntity se1 = new TestEntity("ISPN-1949", "Allow non-indexed values in indexed caches", 10, "note"); cache.put(se1.getId(), se1); cache.put("name2", "some string value"); cache.put("name3", "some string value"); cache.put("name3", new NotIndexedType("some string value")); SearchManager qf = Search.getSearchManager(cache); Query ispnIssueQuery = qf.buildQueryBuilderForClass(TestEntity.class) .get() .keyword() .onField("name") .ignoreAnalyzer() .matching("ISPN-1949") .createQuery(); assertEquals(1, qf.getQuery(ispnIssueQuery).list().size()); cache.put(se1.getId(), "some string value"); assertEquals(0, qf.getQuery(ispnIssueQuery).list().size()); AnotherTestEntity indexBEntity = new AnotherTestEntity("ISPN-1949"); cache.put("name", indexBEntity); assertEquals(1, qf.getQuery(ispnIssueQuery).list().size()); TestEntity se2 = new TestEntity( "HSEARCH-1077", "Mutable SearchFactory should return which classes are actually going to be indexed", 10, "note"); cache.replace("name", indexBEntity, se2); assertEquals(0, qf.getQuery(ispnIssueQuery).list().size()); Query searchIssueQuery = qf.buildQueryBuilderForClass(TestEntity.class) .get() .keyword() .onField("name") .ignoreAnalyzer() .matching("HSEARCH-1077") .createQuery(); assertEquals(1, qf.getQuery(searchIssueQuery).list().size()); // a failing atomic replace should not change the index: cache.replace("name", "notMatching", "notImportant"); assertEquals(1, qf.getQuery(searchIssueQuery).list().size()); assertEquals(0, qf.getQuery(ispnIssueQuery).list().size()); cache.remove("name"); assertEquals(0, qf.getQuery(searchIssueQuery).list().size()); cache.put("name", se2); assertEquals(1, qf.getQuery(searchIssueQuery).list().size()); cache.put("name", "replacement String"); assertEquals(0, qf.getQuery(searchIssueQuery).list().size()); cache.put("name", se1); assertEquals(1, qf.getQuery(ispnIssueQuery).list().size()); cache.put("second name", se1); assertEquals(2, qf.getQuery(ispnIssueQuery).list().size()); assertEquals(2, qf.getQuery(ispnIssueQuery, TestEntity.class).list().size()); // now actually replace one with a different indexed type (matches same query) cache.replace("name", se1, indexBEntity); assertEquals(2, qf.getQuery(ispnIssueQuery).list().size()); assertEquals(1, qf.getQuery(ispnIssueQuery, TestEntity.class).list().size()); assertEquals(1, qf.getQuery(ispnIssueQuery, AnotherTestEntity.class).list().size()); // replace with a non indexed type cache.replace("name", indexBEntity, new NotIndexedType("this is not indexed")); assertEquals(1, qf.getQuery(ispnIssueQuery).list().size()); }
public void setTestEntity(TestEntity testEntity) { this.testEntity = testEntity; testId = testEntity == null ? null : testEntity.getId(); testEntity__resolvedKey = testId; }