From 25d74ee098205b49627fea7d38c14fe80c7dd9ec Mon Sep 17 00:00:00 2001 From: dshvaika Date: Wed, 24 Jun 2026 19:25:14 +0300 Subject: [PATCH] test(attributes): HTTP integration test for allClientKeys param --- .../server/system/BaseHttpDeviceApiTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/application/src/test/java/org/thingsboard/server/system/BaseHttpDeviceApiTest.java b/application/src/test/java/org/thingsboard/server/system/BaseHttpDeviceApiTest.java index dc28913851..b412567fb8 100644 --- a/application/src/test/java/org/thingsboard/server/system/BaseHttpDeviceApiTest.java +++ b/application/src/test/java/org/thingsboard/server/system/BaseHttpDeviceApiTest.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.system; +import com.fasterxml.jackson.databind.JsonNode; import org.junit.Before; import org.junit.Test; import org.springframework.test.context.TestPropertySource; @@ -74,6 +75,25 @@ public abstract class BaseHttpDeviceApiTest extends AbstractControllerTest { doGetAsync("/api/v1/" + deviceCredentials.getCredentialsId() + "/attributes?clientKeys=keyA,keyB,keyC").andExpect(status().isOk()); } + @Test + public void testGetAllClientAttributesViaAllClientKeysParam() throws Exception { + String token = deviceCredentials.getCredentialsId(); + Map clientAttrs = new HashMap<>(); + clientAttrs.put("clientA", "valueA"); + clientAttrs.put("clientB", "valueB"); + mockMvc.perform( + asyncDispatch(doPost("/api/v1/" + token + "/attributes", clientAttrs, new String[]{}).andReturn())) + .andExpect(status().isOk()); + Thread.sleep(2000); + String body = doGetAsync("/api/v1/" + token + "/attributes?allClientKeys=true") + .andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + JsonNode resp = JacksonUtil.toJsonNode(body); + assertThat(resp.has("client")).isTrue(); + assertThat(resp.get("client").get("clientA").asText()).isEqualTo("valueA"); + assertThat(resp.get("client").get("clientB").asText()).isEqualTo("valueB"); + assertThat(resp.has("shared")).isFalse(); + } + @Test public void testReplyToCommandWithLargeResponse() throws Exception { String errorResponse = doPost("/api/v1/" + deviceCredentials.getCredentialsId() + "/rpc/5",