Fix code smells.

Signed-off-by: Marcel Mager (INST-IOT/ESB) <Marcel.Mager@bosch-si.com>
This commit is contained in:
Marcel Mager (INST-IOT/ESB)
2016-09-23 09:57:23 +02:00
parent 52576a4489
commit ab7c2d6a61
7 changed files with 69 additions and 38 deletions

View File

@@ -17,6 +17,12 @@ import org.eclipse.hawkbit.tenancy.configuration.DurationHelper;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.springframework.stereotype.Service;
/**
* Service that calculates non-persistent timestamps , e.g. the point a time a
* target is declared as overdue.<br>
* Therefore tenant specific configuration may be considered.
*
*/
@Service
public class TimestampCalculator {
@@ -33,10 +39,8 @@ public class TimestampCalculator {
* value
*/
public long calculateOverdueTimestamp() {
long overdueTs = Instant.now().toEpochMilli() //
- getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis() //
return Instant.now().toEpochMilli() - getDurationForKey(TenantConfigurationKey.POLLING_TIME_INTERVAL).toMillis()
- getDurationForKey(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL).toMillis();
return overdueTs;
}
private Duration getDurationForKey(TenantConfigurationKey key) {

View File

@@ -446,8 +446,8 @@ public final class RSQLUtility {
final Object transformedValue = transformedValues.get(0);
final String value;
if (virtualPropertyLookup != null) { // if lookup is available,
// replace macros ...
// if lookup is available, replace macros ...
if (virtualPropertyLookup != null) {
value = substitutor.replace(values.get(0));
} else {
value = values.get(0);
@@ -596,7 +596,7 @@ public final class RSQLUtility {
/**
* Adapts the <code>VirtualPropertyLookup</code> to <code>StrLookup</code>.
*/
final static class StrLookupAdapter extends StrLookup<String> {
static final class StrLookupAdapter extends StrLookup<String> {
private VirtualPropertyLookup virtualPropertyLookup;

View File

@@ -24,5 +24,5 @@ public interface VirtualPropertyLookup {
* @return the value for the placeholder; may be <code>null</code> if no
* value could be found for the given placeholder;
*/
public String lookup(String placeholder);
String lookup(String placeholder);
}

View File

@@ -76,7 +76,7 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + placeholder;
String resolvedPlaceholders = substitutor.replace(testString);
assertFalse(resolvedPlaceholders.contains(placeholder));
assertFalse("NOW_TS has to be resolved!", resolvedPlaceholders.contains(placeholder));
}
@Test
@@ -86,7 +86,7 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + placeholder;
String resolvedPlaceholders = substitutor.replace(testString);
assertFalse(resolvedPlaceholders.contains(placeholder));
assertFalse("OVERDUE_TS has to be resolved!", resolvedPlaceholders.contains(placeholder));
}
@Test
@@ -96,7 +96,7 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + placeholder;
String resolvedPlaceholders = substitutor.replace(testString);
assertFalse(resolvedPlaceholders.contains(placeholder));
assertFalse("overdue_ts has to be resolved!", resolvedPlaceholders.contains(placeholder));
}
@Test
@@ -106,7 +106,7 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + placeholder;
String resolvedPlaceholders = substitutor.replace(testString);
assertTrue(resolvedPlaceholders.contains(placeholder));
assertTrue("unknown should not be resolved!", resolvedPlaceholders.contains(placeholder));
}
@Test
@@ -117,6 +117,6 @@ public class VirtualPropertyResolverTest {
String testString = "lhs=lt=" + escaptedPlaceholder;
String resolvedPlaceholders = substitutor.replace(testString);
assertTrue(resolvedPlaceholders.contains(placeholder));
assertTrue("Escaped OVERDUE_TS should not be resolved!", resolvedPlaceholders.contains(placeholder));
}
}