Changed VirtualPropertyResolver to accept TimestampCalculator in the constructor
Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
package org.eclipse.hawkbit.autoconfigure.repository;
|
package org.eclipse.hawkbit.autoconfigure.repository;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.EnableJpaRepository;
|
import org.eclipse.hawkbit.EnableJpaRepository;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.TimestampCalculator;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.VirtualPropertyResolver;
|
import org.eclipse.hawkbit.repository.jpa.rsql.VirtualPropertyResolver;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
@@ -33,7 +34,7 @@ public class JpaRepositoryAutoConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public VirtualPropertyReplacer virtualPropertyReplacer() {
|
public VirtualPropertyReplacer virtualPropertyReplacer() {
|
||||||
return new VirtualPropertyResolver();
|
return new VirtualPropertyResolver(new TimestampCalculator());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,10 +43,21 @@ import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
|||||||
*/
|
*/
|
||||||
public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyReplacer {
|
public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyReplacer {
|
||||||
|
|
||||||
private final TimestampCalculator timestampCalculator = new TimestampCalculator();
|
private final TimestampCalculator timestampCalculator;
|
||||||
|
|
||||||
private StrSubstitutor substitutor;
|
private StrSubstitutor substitutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new virtual property resolver with the given timestamp
|
||||||
|
* calculator
|
||||||
|
*
|
||||||
|
* @param timestampCalculator
|
||||||
|
* calculates timestamps
|
||||||
|
*/
|
||||||
|
public VirtualPropertyResolver(TimestampCalculator timestampCalculator) {
|
||||||
|
this.timestampCalculator = timestampCalculator;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String lookup(String rhs) {
|
public String lookup(String rhs) {
|
||||||
String resolved = null;
|
String resolved = null;
|
||||||
|
|||||||
@@ -441,12 +441,10 @@ public final class RSQLUtility {
|
|||||||
// methods.
|
// methods.
|
||||||
final Object transformedValue = transformedValues.get(0);
|
final Object transformedValue = transformedValues.get(0);
|
||||||
|
|
||||||
final String value;
|
String value = values.get(0);
|
||||||
// if lookup is available, replace macros ...
|
// if lookup is available, replace macros ...
|
||||||
if (virtualPropertyReplacer != null) {
|
if (virtualPropertyReplacer != null) {
|
||||||
value = virtualPropertyReplacer.replace(values.get(0));
|
value = virtualPropertyReplacer.replace(value);
|
||||||
} else {
|
|
||||||
value = values.get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Predicate> singleList = new ArrayList<>();
|
final List<Predicate> singleList = new ArrayList<>();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
public class RSQLUtilityTest {
|
public class RSQLUtilityTest {
|
||||||
|
|
||||||
@Spy
|
@Spy
|
||||||
VirtualPropertyResolver macroResolver = new VirtualPropertyResolver();
|
VirtualPropertyResolver macroResolver = new VirtualPropertyResolver(new TimestampCalculator());
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
TenantConfigurationManagement confMgmt;
|
TenantConfigurationManagement confMgmt;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
|||||||
public class VirtualPropertyResolverTest {
|
public class VirtualPropertyResolverTest {
|
||||||
|
|
||||||
@Spy
|
@Spy
|
||||||
VirtualPropertyResolver resolverUnderTest = new VirtualPropertyResolver();
|
VirtualPropertyResolver resolverUnderTest = new VirtualPropertyResolver(new TimestampCalculator());
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
TenantConfigurationManagement confMgmt;
|
TenantConfigurationManagement confMgmt;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.util.concurrent.Executors;
|
|||||||
import org.eclipse.hawkbit.cache.CacheConstants;
|
import org.eclipse.hawkbit.cache.CacheConstants;
|
||||||
import org.eclipse.hawkbit.cache.TenancyCacheManager;
|
import org.eclipse.hawkbit.cache.TenancyCacheManager;
|
||||||
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
|
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
|
||||||
|
import org.eclipse.hawkbit.repository.jpa.TimestampCalculator;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EventBusHolder;
|
||||||
import org.eclipse.hawkbit.repository.jpa.rsql.VirtualPropertyResolver;
|
import org.eclipse.hawkbit.repository.jpa.rsql.VirtualPropertyResolver;
|
||||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||||
@@ -128,7 +129,7 @@ public class TestConfiguration implements AsyncConfigurer {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public VirtualPropertyReplacer virtualPropertyReplacer() {
|
public VirtualPropertyReplacer virtualPropertyReplacer() {
|
||||||
return new VirtualPropertyResolver();
|
return new VirtualPropertyResolver(new TimestampCalculator());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user