Skip to content

Commit

Permalink
#68 - Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
starnowski committed Dec 17, 2023
1 parent 9e99063 commit 573dbf9
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.github.starnowski.posjsonhelper.core.CoreContextPropertiesSupplier;
import com.github.starnowski.posjsonhelper.core.HibernateContext;
import com.github.starnowski.posjsonhelper.core.HibernateContextPropertiesSupplier;
import com.github.starnowski.posjsonhelper.hibernate6.descriptor.AbstractConditionalFunctionDescriptorRegister;
import com.github.starnowski.posjsonhelper.hibernate6.descriptor.FunctionDescriptorRegisterFactoriesSupplier;
import com.github.starnowski.posjsonhelper.hibernate6.descriptor.FunctionDescriptorRegisterFactory;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
Expand All @@ -35,7 +34,7 @@
/**
* The component that enriches the {@link SqmFunctionRegistry} object with Hibernate and SQL definitions used by the library.
*/
public class SqmFunctionRegistryEnricherX {
public class SqmFunctionRegistryEnricher {

/**
* Supplier for {@link Context} object based on system properties
Expand All @@ -47,11 +46,11 @@ public class SqmFunctionRegistryEnricherX {
private final HibernateContextPropertiesSupplier hibernateContextPropertiesSupplier;
private final List<FunctionDescriptorRegisterFactory> functionDescriptorRegisterFactories;

public SqmFunctionRegistryEnricherX() {
public SqmFunctionRegistryEnricher() {
this(new CoreContextPropertiesSupplier(), new HibernateContextPropertiesSupplier(), new FunctionDescriptorRegisterFactoriesSupplier());
}

SqmFunctionRegistryEnricherX(CoreContextPropertiesSupplier coreContextPropertiesSupplier, HibernateContextPropertiesSupplier hibernateContextPropertiesSupplier, FunctionDescriptorRegisterFactoriesSupplier functionDescriptorRegisterFactoriesSupplier) {
SqmFunctionRegistryEnricher(CoreContextPropertiesSupplier coreContextPropertiesSupplier, HibernateContextPropertiesSupplier hibernateContextPropertiesSupplier, FunctionDescriptorRegisterFactoriesSupplier functionDescriptorRegisterFactoriesSupplier) {
this.coreContextPropertiesSupplier = coreContextPropertiesSupplier;
this.hibernateContextPropertiesSupplier = hibernateContextPropertiesSupplier;
this.functionDescriptorRegisterFactories = functionDescriptorRegisterFactoriesSupplier.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@ import com.github.starnowski.posjsonhelper.core.Context
import com.github.starnowski.posjsonhelper.core.CoreContextPropertiesSupplier
import com.github.starnowski.posjsonhelper.core.HibernateContext
import com.github.starnowski.posjsonhelper.core.HibernateContextPropertiesSupplier
import com.github.starnowski.posjsonhelper.hibernate6.descriptor.AbstractConditionalFunctionDescriptorRegister
import com.github.starnowski.posjsonhelper.hibernate6.descriptor.FunctionDescriptorRegister
import com.github.starnowski.posjsonhelper.hibernate6.descriptor.FunctionDescriptorRegisterFactoriesSupplier
import com.github.starnowski.posjsonhelper.hibernate6.descriptor.FunctionDescriptorRegisterFactory
import org.hibernate.query.sqm.function.AbstractSqmFunctionDescriptor
import org.hibernate.query.sqm.function.SqmFunctionDescriptor
import org.hibernate.query.sqm.function.SqmFunctionRegistry
import spock.lang.Specification
import spock.lang.Unroll

import java.util.function.Function
import java.util.stream.Collectors

class SqmFunctionRegistryEnricherXTest extends Specification {
class SqmFunctionRegistryEnricherTest extends Specification {

// @Unroll
def "should enrich sqmFunctionRegistry with expected functions types #expectedFunctionTypes"() {
Expand All @@ -34,7 +31,7 @@ class SqmFunctionRegistryEnricherXTest extends Specification {
hibernateContextPropertiesSupplier.get() >> hibernateContext
functionDescriptorRegisterFactoriesSupplier.get() >> [functionDescriptorRegisterFactory]
functionDescriptorRegisterFactory.get(context, hibernateContext) >> functionDescriptorRegister
def tested = new SqmFunctionRegistryEnricherX(coreContextPropertiesSupplier, hibernateContextPropertiesSupplier, functionDescriptorRegisterFactoriesSupplier)
def tested = new SqmFunctionRegistryEnricher(coreContextPropertiesSupplier, hibernateContextPropertiesSupplier, functionDescriptorRegisterFactoriesSupplier)

when:
tested.enrich(sqmFunctionRegistry)
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 573dbf9

Please sign in to comment.