Skip to content

Commit

Permalink
HBX-2754: Create Interface for JoinWrapper
Browse files Browse the repository at this point in the history
  - Add new test case 'org.hibernate.tool.orm.jbt.api.HqlCompletionProposalWrapperTest#testGetPropertyIterator()'
  - Add new test case 'org.hibernate.tool.orm.jbt.api.HqlCompletionProposalWrapperTest#getPropertyIterator()'

Signed-off-by: Koen Aers <koen.aers@gmail.com>
  • Loading branch information
koentsje committed Mar 19, 2024
1 parent 84e7ad8 commit 22d381c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package org.hibernate.tool.orm.jbt.api;

import java.util.Iterator;

import org.hibernate.mapping.Join;
import org.hibernate.mapping.Property;
import org.hibernate.tool.orm.jbt.wrp.Wrapper;

public interface JoinWrapper extends Wrapper {

default Iterator<Property> getPropertyIterator() {
return ((Join)getWrappedObject()).getProperties().iterator();
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package org.hibernate.tool.orm.jbt.api;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Iterator;

import org.hibernate.mapping.Join;
import org.hibernate.mapping.Property;
import org.hibernate.tool.orm.jbt.internal.factory.JoinWrapperFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -24,4 +30,16 @@ public void testConstruction() {
assertNotNull(joinWrapper);
}

@Test
public void testGetPropertyIterator() {
Iterator<Property> propertyIterator = joinWrapper.getPropertyIterator();
assertFalse(propertyIterator.hasNext());
Property property = new Property();
wrappedJoin.addProperty(property);
propertyIterator = joinWrapper.getPropertyIterator();
assertTrue(propertyIterator.hasNext());
Property p = propertyIterator.next();
assertSame(p, property);
}

}

0 comments on commit 22d381c

Please sign in to comment.