Skip to content

Commit

Permalink
Timestamps in seconds instead of milliseconds in ManualDataSender
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslawLegierski committed Sep 7, 2022
1 parent b14a740 commit d3cf1a2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.eclipse.leshan.client.servers.ServerIdentity;
import org.eclipse.leshan.core.node.LwM2mNode;
Expand Down Expand Up @@ -44,7 +45,7 @@ public ManualDataSender(String name) {
}

public synchronized void collectData(List<LwM2mPath> paths) {
long currentTimestamp = System.currentTimeMillis();
long currentTimestamp = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
Map<LwM2mPath, LwM2mNode> currentValues = dataSenderManager.getCurrentValues(ServerIdentity.SYSTEM, paths);
synchronized (this) {
builder.addNodes(currentTimestamp, currentValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public void test_collect_several_data() throws InterruptedException {
Map<LwM2mPath, LwM2mNode> firstValue = fakeDataSenderManager.getCurrentValues(givenServer, givenPaths);
manualDataSender.collectData(givenPaths);

Thread.sleep(100);
Thread.sleep(1000);
Map<LwM2mPath, LwM2mNode> secondValue = fakeDataSenderManager.changeCurrentValues(givenServer, givenPaths);
manualDataSender.collectData(givenPaths);

Thread.sleep(100);
Thread.sleep(1000);
Map<LwM2mPath, LwM2mNode> thirdValue = fakeDataSenderManager.changeCurrentValues(givenServer, givenPaths);
manualDataSender.collectData(givenPaths);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void server_handle_multiple_timestamped_node() throws InterruptedExceptio
ManualDataSender sender = helper.client.getSendService().getDataSender(ManualDataSender.DEFAULT_NAME,
ManualDataSender.class);
sender.collectData(Arrays.asList(getExamplePath()));
Thread.sleep(100);
Thread.sleep(1000);
sender.collectData(Arrays.asList(getExamplePath()));
sender.sendCollectedData(server, ContentFormat.SENML_JSON, 1000, false);
listener.waitForData(1, TimeUnit.SECONDS);
Expand Down

0 comments on commit d3cf1a2

Please sign in to comment.