Changed VirtualPropertyResolver to accept TimestampCalculator in the constructor
Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com>
This commit is contained in:
@@ -43,10 +43,21 @@ import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
*/
|
||||
public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyReplacer {
|
||||
|
||||
private final TimestampCalculator timestampCalculator = new TimestampCalculator();
|
||||
private final TimestampCalculator timestampCalculator;
|
||||
|
||||
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
|
||||
public String lookup(String rhs) {
|
||||
String resolved = null;
|
||||
|
||||
@@ -441,12 +441,10 @@ public final class RSQLUtility {
|
||||
// methods.
|
||||
final Object transformedValue = transformedValues.get(0);
|
||||
|
||||
final String value;
|
||||
String value = values.get(0);
|
||||
// if lookup is available, replace macros ...
|
||||
if (virtualPropertyReplacer != null) {
|
||||
value = virtualPropertyReplacer.replace(values.get(0));
|
||||
} else {
|
||||
value = values.get(0);
|
||||
value = virtualPropertyReplacer.replace(value);
|
||||
}
|
||||
|
||||
final List<Predicate> singleList = new ArrayList<>();
|
||||
|
||||
@@ -50,7 +50,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
||||
public class RSQLUtilityTest {
|
||||
|
||||
@Spy
|
||||
VirtualPropertyResolver macroResolver = new VirtualPropertyResolver();
|
||||
VirtualPropertyResolver macroResolver = new VirtualPropertyResolver(new TimestampCalculator());
|
||||
|
||||
@Mock
|
||||
TenantConfigurationManagement confMgmt;
|
||||
|
||||
@@ -36,7 +36,7 @@ import ru.yandex.qatools.allure.annotations.Stories;
|
||||
public class VirtualPropertyResolverTest {
|
||||
|
||||
@Spy
|
||||
VirtualPropertyResolver resolverUnderTest = new VirtualPropertyResolver();
|
||||
VirtualPropertyResolver resolverUnderTest = new VirtualPropertyResolver(new TimestampCalculator());
|
||||
|
||||
@Mock
|
||||
TenantConfigurationManagement confMgmt;
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.concurrent.Executors;
|
||||
import org.eclipse.hawkbit.cache.CacheConstants;
|
||||
import org.eclipse.hawkbit.cache.TenancyCacheManager;
|
||||
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.rsql.VirtualPropertyResolver;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
@@ -128,7 +129,7 @@ public class TestConfiguration implements AsyncConfigurer {
|
||||
*/
|
||||
@Bean
|
||||
public VirtualPropertyReplacer virtualPropertyReplacer() {
|
||||
return new VirtualPropertyResolver();
|
||||
return new VirtualPropertyResolver(new TimestampCalculator());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user