Skip to content

Commit

Permalink
GH-1575: fix ObserveCompositeTimestampTests to make it works on JDK 17+
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Jan 16, 2024
1 parent 1cdb0db commit 9693a3d
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -130,8 +131,8 @@ public void can_observecomposite_timestamped_resource(ContentFormat contentForma

// and expected Time-stamped nodes
TimestampedLwM2mNodes.Builder builder = new TimestampedLwM2mNodes.Builder();
Instant t1 = Instant.now();
Instant t2 = Instant.now().minusSeconds(2000);
Instant t1 = Instant.now().truncatedTo(ChronoUnit.MILLIS);
Instant t2 = Instant.now().truncatedTo(ChronoUnit.MILLIS).minusSeconds(2000);
builder.put(t1, paths.get(0), LwM2mSingleResource.newIntegerResource(1, 3600));
builder.put(t1, paths.get(1), LwM2mSingleResource.newStringResource(15, "Europe/Belgrade"));
builder.put(t2, paths.get(0), LwM2mSingleResource.newIntegerResource(1, 500));
Expand All @@ -153,8 +154,8 @@ public void can_observecomposite_timestamped_resource_with_empty_value(ContentFo

// and expected Time-stamped nodes
TimestampedLwM2mNodes.Builder builder = new TimestampedLwM2mNodes.Builder();
Instant t1 = Instant.now();
Instant t2 = Instant.now().minusSeconds(2000);
Instant t1 = Instant.now().truncatedTo(ChronoUnit.MILLIS);
Instant t2 = Instant.now().truncatedTo(ChronoUnit.MILLIS).minusSeconds(2000);
builder.put(t1, paths.get(0), null);
builder.put(t1, paths.get(1), LwM2mSingleResource.newStringResource(15, "Europe/Belgrade"));
builder.put(t2, paths.get(0), LwM2mSingleResource.newIntegerResource(1, 500));
Expand Down Expand Up @@ -194,7 +195,7 @@ public void can_observecomposite_timestamped_instance(ContentFormat contentForma
deviceresources.add(LwM2mSingleResource.newIntegerResource(21, 20500736));

TimestampedLwM2mNodes.Builder builder = new TimestampedLwM2mNodes.Builder();
Instant t1 = Instant.now();
Instant t1 = Instant.now().truncatedTo(ChronoUnit.MILLIS);
builder.put(t1, paths.get(0), LwM2mSingleResource.newIntegerResource(1, 3600));
builder.put(t1, paths.get(1), new LwM2mObjectInstance(0, deviceresources));
TimestampedLwM2mNodes timestampednodes = builder.build();
Expand Down Expand Up @@ -232,7 +233,7 @@ public void can_observecomposite__timestamped_object(ContentFormat contentFormat
deviceresources.add(LwM2mSingleResource.newIntegerResource(21, 20500736));

TimestampedLwM2mNodes.Builder builder = new TimestampedLwM2mNodes.Builder();
Instant t1 = Instant.now();
Instant t1 = Instant.now().truncatedTo(ChronoUnit.MILLIS);
builder.put(t1, paths.get(0), LwM2mSingleResource.newIntegerResource(1, 3600));
builder.put(t1, paths.get(1), new LwM2mObject(3, new LwM2mObjectInstance(0, deviceresources)));
TimestampedLwM2mNodes timestampednodes = builder.build();
Expand Down Expand Up @@ -287,8 +288,8 @@ public void reject_observecomposite_response_for_unexpected_resource_path(Conten

// and expected Time-stamped nodes
TimestampedLwM2mNodes.Builder builder = new TimestampedLwM2mNodes.Builder();
Instant t1 = Instant.now();
Instant t2 = Instant.now().minusSeconds(2000);
Instant t1 = Instant.now().truncatedTo(ChronoUnit.MILLIS);
Instant t2 = Instant.now().truncatedTo(ChronoUnit.MILLIS).minusSeconds(2000);
builder.put(t1, paths.get(0), LwM2mSingleResource.newIntegerResource(1, 3600));
builder.put(t1, paths.get(1), LwM2mSingleResource.newStringResource(15, "Europe/Belgrade"));
builder.put(t1, new LwM2mPath(1, 0, 0), LwM2mSingleResource.newIntegerResource(0, 123));
Expand Down Expand Up @@ -331,7 +332,7 @@ public void reject_observecomposite_response_for_unexpected_instance_path(Conten
deviceresources.add(LwM2mSingleResource.newIntegerResource(21, 20500736));

TimestampedLwM2mNodes.Builder builder = new TimestampedLwM2mNodes.Builder();
Instant t1 = Instant.now();
Instant t1 = Instant.now().truncatedTo(ChronoUnit.MILLIS);
builder.put(t1, paths.get(0), LwM2mSingleResource.newIntegerResource(1, 3600));
builder.put(t1, paths.get(1), new LwM2mObjectInstance(0, deviceresources));
builder.put(t1, new LwM2mPath(3, 1), new LwM2mObjectInstance(1, deviceresources));
Expand Down

0 comments on commit 9693a3d

Please sign in to comment.