committed by
GitHub
37 changed files with 699 additions and 39 deletions
@ -0,0 +1,67 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2023 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.service.edge.rpc.constructor; |
||||
|
|
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.thingsboard.common.util.JacksonUtil; |
||||
|
import org.thingsboard.server.common.data.Tenant; |
||||
|
import org.thingsboard.server.gen.edge.v1.TenantUpdateMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.UpdateMsgType; |
||||
|
import org.thingsboard.server.queue.util.TbCoreComponent; |
||||
|
|
||||
|
@Component |
||||
|
@TbCoreComponent |
||||
|
public class TenantMsgConstructor { |
||||
|
|
||||
|
public TenantUpdateMsg constructTenantUpdateMsg(UpdateMsgType msgType, Tenant tenant) { |
||||
|
TenantUpdateMsg.Builder builder = TenantUpdateMsg.newBuilder() |
||||
|
.setMsgType(msgType) |
||||
|
.setIdMSB(tenant.getId().getId().getMostSignificantBits()) |
||||
|
.setIdLSB(tenant.getId().getId().getLeastSignificantBits()) |
||||
|
.setTitle(tenant.getTitle()) |
||||
|
.setProfileIdMSB(tenant.getTenantProfileId().getId().getMostSignificantBits()) |
||||
|
.setProfileIdLSB(tenant.getTenantProfileId().getId().getLeastSignificantBits()) |
||||
|
.setRegion(tenant.getRegion()); |
||||
|
if (tenant.getCountry() != null) { |
||||
|
builder.setCountry(tenant.getCountry()); |
||||
|
} |
||||
|
if (tenant.getState() != null) { |
||||
|
builder.setState(tenant.getState()); |
||||
|
} |
||||
|
if (tenant.getCity() != null) { |
||||
|
builder.setCity(tenant.getCity()); |
||||
|
} |
||||
|
if (tenant.getAddress() != null) { |
||||
|
builder.setAddress(tenant.getAddress()); |
||||
|
} |
||||
|
if (tenant.getAddress2() != null) { |
||||
|
builder.setAddress2(tenant.getAddress2()); |
||||
|
} |
||||
|
if (tenant.getZip() != null) { |
||||
|
builder.setZip(tenant.getZip()); |
||||
|
} |
||||
|
if (tenant.getPhone() != null) { |
||||
|
builder.setPhone(tenant.getPhone()); |
||||
|
} |
||||
|
if (tenant.getEmail() != null) { |
||||
|
builder.setEmail(tenant.getEmail()); |
||||
|
} |
||||
|
if (tenant.getAdditionalInfo() != null) { |
||||
|
builder.setAdditionalInfo(JacksonUtil.toString(tenant.getAdditionalInfo())); |
||||
|
} |
||||
|
return builder.build(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2023 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.service.edge.rpc.constructor; |
||||
|
|
||||
|
import com.google.protobuf.ByteString; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.thingsboard.server.common.data.TenantProfile; |
||||
|
import org.thingsboard.server.gen.edge.v1.TenantProfileUpdateMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.UpdateMsgType; |
||||
|
import org.thingsboard.server.queue.util.DataDecodingEncodingService; |
||||
|
import org.thingsboard.server.queue.util.TbCoreComponent; |
||||
|
|
||||
|
@Component |
||||
|
@TbCoreComponent |
||||
|
public class TenantProfileMsgConstructor { |
||||
|
|
||||
|
@Autowired |
||||
|
private DataDecodingEncodingService dataDecodingEncodingService; |
||||
|
|
||||
|
public TenantProfileUpdateMsg constructTenantProfileUpdateMsg(UpdateMsgType msgType, TenantProfile tenantProfile) { |
||||
|
TenantProfileUpdateMsg.Builder builder = TenantProfileUpdateMsg.newBuilder() |
||||
|
.setMsgType(msgType) |
||||
|
.setIdMSB(tenantProfile.getId().getId().getMostSignificantBits()) |
||||
|
.setIdLSB(tenantProfile.getId().getId().getLeastSignificantBits()) |
||||
|
.setName(tenantProfile.getName()) |
||||
|
.setDefault(tenantProfile.isDefault()) |
||||
|
.setIsolatedRuleChain(tenantProfile.isIsolatedTbRuleEngine()) |
||||
|
.setProfileDataBytes(ByteString.copyFrom(dataDecodingEncodingService.encode(tenantProfile.getProfileData()))); |
||||
|
if (tenantProfile.getDescription() != null) { |
||||
|
builder.setDescription(tenantProfile.getDescription()); |
||||
|
} |
||||
|
return builder.build(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2023 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.service.edge.rpc.fetch; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.thingsboard.server.common.data.EdgeUtils; |
||||
|
import org.thingsboard.server.common.data.Tenant; |
||||
|
import org.thingsboard.server.common.data.edge.Edge; |
||||
|
import org.thingsboard.server.common.data.edge.EdgeEvent; |
||||
|
import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
||||
|
import org.thingsboard.server.common.data.edge.EdgeEventType; |
||||
|
import org.thingsboard.server.common.data.id.TenantId; |
||||
|
import org.thingsboard.server.common.data.page.PageData; |
||||
|
import org.thingsboard.server.common.data.page.PageLink; |
||||
|
import org.thingsboard.server.dao.tenant.TenantService; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@AllArgsConstructor |
||||
|
@Slf4j |
||||
|
public class TenantEdgeEventFetcher extends BasePageableEdgeEventFetcher<Tenant> { |
||||
|
|
||||
|
private final TenantService tenantService; |
||||
|
|
||||
|
@Override |
||||
|
PageData<Tenant> fetchPageData(TenantId tenantId, Edge edge, PageLink pageLink) { |
||||
|
Tenant tenant = tenantService.findTenantById(tenantId); |
||||
|
// returns PageData object to be in sync with other fetchers
|
||||
|
return new PageData<>(List.of(tenant), 1, 1, false); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
EdgeEvent constructEdgeEvent(TenantId tenantId, Edge edge, Tenant entity) { |
||||
|
return EdgeUtils.constructEdgeEvent(tenantId, edge.getId(), EdgeEventType.TENANT, |
||||
|
EdgeEventActionType.UPDATED, entity.getId(), null); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2023 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.service.edge.rpc.processor.tenant; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.thingsboard.server.common.data.EdgeUtils; |
||||
|
import org.thingsboard.server.common.data.Tenant; |
||||
|
import org.thingsboard.server.common.data.TenantProfile; |
||||
|
import org.thingsboard.server.common.data.edge.EdgeEvent; |
||||
|
import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
||||
|
import org.thingsboard.server.common.data.id.TenantId; |
||||
|
import org.thingsboard.server.gen.edge.v1.DownlinkMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.TenantProfileUpdateMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.TenantUpdateMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.UpdateMsgType; |
||||
|
import org.thingsboard.server.queue.util.TbCoreComponent; |
||||
|
import org.thingsboard.server.service.edge.rpc.processor.BaseEdgeProcessor; |
||||
|
|
||||
|
@Component |
||||
|
@Slf4j |
||||
|
@TbCoreComponent |
||||
|
public class TenantEdgeProcessor extends BaseEdgeProcessor { |
||||
|
|
||||
|
public DownlinkMsg convertTenantEventToDownlink(EdgeEvent edgeEvent) { |
||||
|
TenantId tenantId = new TenantId(edgeEvent.getEntityId()); |
||||
|
DownlinkMsg downlinkMsg = null; |
||||
|
if (EdgeEventActionType.UPDATED.equals(edgeEvent.getAction())) { |
||||
|
Tenant tenant = tenantService.findTenantById(tenantId); |
||||
|
if (tenant != null) { |
||||
|
UpdateMsgType msgType = getUpdateMsgType(edgeEvent.getAction()); |
||||
|
TenantUpdateMsg tenantUpdateMsg = tenantMsgConstructor.constructTenantUpdateMsg(msgType, tenant); |
||||
|
TenantProfile tenantProfile = tenantProfileService.findTenantProfileById(tenantId, tenant.getTenantProfileId()); |
||||
|
TenantProfileUpdateMsg tenantProfileUpdateMsg = tenantProfileMsgConstructor.constructTenantProfileUpdateMsg(msgType, tenantProfile); |
||||
|
downlinkMsg = DownlinkMsg.newBuilder() |
||||
|
.setDownlinkMsgId(EdgeUtils.nextPositiveInt()) |
||||
|
.addTenantUpdateMsg(tenantUpdateMsg) |
||||
|
.addTenantProfileUpdateMsg(tenantProfileUpdateMsg) |
||||
|
.build(); |
||||
|
} |
||||
|
} |
||||
|
return downlinkMsg; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2023 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.service.edge.rpc.processor.tenant; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.thingsboard.server.common.data.EdgeUtils; |
||||
|
import org.thingsboard.server.common.data.TenantProfile; |
||||
|
import org.thingsboard.server.common.data.edge.EdgeEvent; |
||||
|
import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
||||
|
import org.thingsboard.server.common.data.id.TenantProfileId; |
||||
|
import org.thingsboard.server.gen.edge.v1.DownlinkMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.TenantProfileUpdateMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.UpdateMsgType; |
||||
|
import org.thingsboard.server.queue.util.TbCoreComponent; |
||||
|
import org.thingsboard.server.service.edge.rpc.processor.BaseEdgeProcessor; |
||||
|
|
||||
|
@Component |
||||
|
@Slf4j |
||||
|
@TbCoreComponent |
||||
|
public class TenantProfileEdgeProcessor extends BaseEdgeProcessor { |
||||
|
|
||||
|
public DownlinkMsg convertTenantProfileEventToDownlink(EdgeEvent edgeEvent) { |
||||
|
TenantProfileId tenantProfileId = new TenantProfileId(edgeEvent.getEntityId()); |
||||
|
DownlinkMsg downlinkMsg = null; |
||||
|
if (EdgeEventActionType.UPDATED.equals(edgeEvent.getAction())) { |
||||
|
TenantProfile tenantProfile = tenantProfileService.findTenantProfileById(edgeEvent.getTenantId(), tenantProfileId); |
||||
|
if (tenantProfile != null) { |
||||
|
UpdateMsgType msgType = getUpdateMsgType(edgeEvent.getAction()); |
||||
|
TenantProfileUpdateMsg tenantProfileUpdateMsg = |
||||
|
tenantProfileMsgConstructor.constructTenantProfileUpdateMsg(msgType, tenantProfile); |
||||
|
downlinkMsg = DownlinkMsg.newBuilder() |
||||
|
.setDownlinkMsgId(EdgeUtils.nextPositiveInt()) |
||||
|
.addTenantProfileUpdateMsg(tenantProfileUpdateMsg) |
||||
|
.build(); |
||||
|
} |
||||
|
} |
||||
|
return downlinkMsg; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,90 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2023 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.edge; |
||||
|
|
||||
|
import org.junit.Assert; |
||||
|
import org.junit.Test; |
||||
|
import org.thingsboard.server.common.data.Tenant; |
||||
|
import org.thingsboard.server.common.data.TenantProfile; |
||||
|
import org.thingsboard.server.common.data.id.TenantProfileId; |
||||
|
import org.thingsboard.server.dao.service.DaoSqlTest; |
||||
|
import org.thingsboard.server.gen.edge.v1.TenantProfileUpdateMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.TenantUpdateMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.UpdateMsgType; |
||||
|
|
||||
|
import java.util.Optional; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
@DaoSqlTest |
||||
|
public class TenantEdgeTest extends AbstractEdgeTest { |
||||
|
|
||||
|
@Test |
||||
|
public void testUpdateTenant() throws Exception { |
||||
|
loginSysAdmin(); |
||||
|
|
||||
|
// save current value into tmp to revert after test
|
||||
|
Tenant savedTenant = doGet("/api/tenant/" + tenantId, Tenant.class); |
||||
|
|
||||
|
// updated edge tenant
|
||||
|
savedTenant.setTitle("Updated Title for Tenant Edge Test"); |
||||
|
edgeImitator.expectMessageAmount(2); // expect tenant and tenant profile update msg
|
||||
|
savedTenant = doPost("/api/tenant", savedTenant, Tenant.class); |
||||
|
Assert.assertTrue(edgeImitator.waitForMessages()); |
||||
|
Optional<TenantUpdateMsg> tenantUpdateMsgOpt = edgeImitator.findMessageByType(TenantUpdateMsg.class); |
||||
|
Assert.assertTrue(tenantUpdateMsgOpt.isPresent()); |
||||
|
TenantUpdateMsg tenantUpdateMsg = tenantUpdateMsgOpt.get(); |
||||
|
Optional<TenantProfileUpdateMsg> tenantProfileUpdateMsgOpt = edgeImitator.findMessageByType(TenantProfileUpdateMsg.class); |
||||
|
Assert.assertTrue(tenantProfileUpdateMsgOpt.isPresent()); |
||||
|
TenantProfileUpdateMsg tenantProfileUpdateMsg = tenantProfileUpdateMsgOpt.get(); |
||||
|
Assert.assertEquals(UpdateMsgType.ENTITY_UPDATED_RPC_MESSAGE, tenantUpdateMsg.getMsgType()); |
||||
|
Assert.assertEquals(savedTenant.getUuidId().getMostSignificantBits(), tenantUpdateMsg.getIdMSB()); |
||||
|
Assert.assertEquals(savedTenant.getUuidId().getLeastSignificantBits(), tenantUpdateMsg.getIdLSB()); |
||||
|
Assert.assertEquals(savedTenant.getTitle(), tenantUpdateMsg.getTitle()); |
||||
|
Assert.assertEquals("Updated Title for Tenant Edge Test", tenantUpdateMsg.getTitle()); |
||||
|
Assert.assertEquals(savedTenant.getTenantProfileId(), new TenantProfileId |
||||
|
(new UUID(tenantUpdateMsg.getProfileIdMSB(), tenantUpdateMsg.getProfileIdLSB()))); |
||||
|
Assert.assertEquals(savedTenant.getTenantProfileId(), new TenantProfileId |
||||
|
(new UUID(tenantProfileUpdateMsg.getIdMSB(), tenantProfileUpdateMsg.getIdLSB()))); |
||||
|
|
||||
|
//change tenant profile for tenant
|
||||
|
TenantProfile tenantProfile = createTenantProfile(); |
||||
|
savedTenant.setTenantProfileId(tenantProfile.getId()); |
||||
|
edgeImitator.expectMessageAmount(2); // expect tenant and tenant profile update msg
|
||||
|
savedTenant = doPost("/api/tenant", savedTenant, Tenant.class); |
||||
|
Assert.assertTrue(edgeImitator.waitForMessages()); |
||||
|
tenantUpdateMsgOpt = edgeImitator.findMessageByType(TenantUpdateMsg.class); |
||||
|
Assert.assertTrue(tenantUpdateMsgOpt.isPresent()); |
||||
|
tenantUpdateMsg = tenantUpdateMsgOpt.get(); |
||||
|
tenantProfileUpdateMsgOpt = edgeImitator.findMessageByType(TenantProfileUpdateMsg.class); |
||||
|
Assert.assertTrue(tenantProfileUpdateMsgOpt.isPresent()); |
||||
|
tenantProfileUpdateMsg = tenantProfileUpdateMsgOpt.get(); |
||||
|
// tenant update
|
||||
|
Assert.assertEquals(UpdateMsgType.ENTITY_UPDATED_RPC_MESSAGE, tenantUpdateMsg.getMsgType()); |
||||
|
Assert.assertEquals(savedTenant.getUuidId().getMostSignificantBits(), tenantUpdateMsg.getIdMSB()); |
||||
|
Assert.assertEquals(savedTenant.getUuidId().getLeastSignificantBits(), tenantUpdateMsg.getIdLSB()); |
||||
|
Assert.assertEquals(savedTenant.getTitle(), tenantUpdateMsg.getTitle()); |
||||
|
Assert.assertEquals(savedTenant.getTenantProfileId(), new TenantProfileId |
||||
|
(new UUID(tenantUpdateMsg.getProfileIdMSB(), tenantUpdateMsg.getProfileIdLSB()))); |
||||
|
Assert.assertEquals(savedTenant.getTenantProfileId(), new TenantProfileId |
||||
|
(new UUID(tenantProfileUpdateMsg.getIdMSB(), tenantProfileUpdateMsg.getIdLSB()))); |
||||
|
} |
||||
|
|
||||
|
private TenantProfile createTenantProfile() { |
||||
|
TenantProfile tenantProfile = new TenantProfile(); |
||||
|
tenantProfile.setName("TestEdge tenant profile"); |
||||
|
return doPost("/api/tenantProfile", tenantProfile, TenantProfile.class); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,54 @@ |
|||||
|
/** |
||||
|
* Copyright © 2016-2023 The Thingsboard Authors |
||||
|
* |
||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
|
* you may not use this file except in compliance with the License. |
||||
|
* You may obtain a copy of the License at |
||||
|
* |
||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
* |
||||
|
* Unless required by applicable law or agreed to in writing, software |
||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
|
* See the License for the specific language governing permissions and |
||||
|
* limitations under the License. |
||||
|
*/ |
||||
|
package org.thingsboard.server.edge; |
||||
|
|
||||
|
import com.google.protobuf.AbstractMessage; |
||||
|
import org.junit.Assert; |
||||
|
import org.junit.Test; |
||||
|
import org.thingsboard.server.common.data.TenantProfile; |
||||
|
import org.thingsboard.server.dao.service.DaoSqlTest; |
||||
|
import org.thingsboard.server.gen.edge.v1.TenantProfileUpdateMsg; |
||||
|
import org.thingsboard.server.gen.edge.v1.UpdateMsgType; |
||||
|
|
||||
|
@DaoSqlTest |
||||
|
public class TenantProfileEdgeTest extends AbstractEdgeTest { |
||||
|
|
||||
|
@Test |
||||
|
public void testTenantProfiles() throws Exception { |
||||
|
loginSysAdmin(); |
||||
|
|
||||
|
// save current values into tmp to revert after test
|
||||
|
TenantProfile edgeTenantProfile = doGet("/api/tenantProfile/" + tenantProfileId.getId(), TenantProfile.class); |
||||
|
|
||||
|
// updated edge tenant profile
|
||||
|
edgeTenantProfile.setName("Tenant Profile Edge Test"); |
||||
|
edgeTenantProfile.setDescription("Updated tenant profile Edge Test"); |
||||
|
edgeImitator.expectMessageAmount(1); |
||||
|
edgeTenantProfile = doPost("/api/tenantProfile", edgeTenantProfile, TenantProfile.class); |
||||
|
Assert.assertTrue(edgeImitator.waitForMessages()); |
||||
|
AbstractMessage latestMessage = edgeImitator.getLatestMessage(); |
||||
|
Assert.assertTrue(latestMessage instanceof TenantProfileUpdateMsg); |
||||
|
TenantProfileUpdateMsg tenantProfileUpdateMsg = (TenantProfileUpdateMsg) latestMessage; |
||||
|
Assert.assertEquals(UpdateMsgType.ENTITY_UPDATED_RPC_MESSAGE, tenantProfileUpdateMsg.getMsgType()); |
||||
|
Assert.assertEquals(edgeTenantProfile.getUuidId().getMostSignificantBits(), tenantProfileUpdateMsg.getIdMSB()); |
||||
|
Assert.assertEquals(edgeTenantProfile.getUuidId().getLeastSignificantBits(), tenantProfileUpdateMsg.getIdLSB()); |
||||
|
Assert.assertEquals(edgeTenantProfile.getDescription(), tenantProfileUpdateMsg.getDescription()); |
||||
|
Assert.assertEquals("Updated tenant profile Edge Test", tenantProfileUpdateMsg.getDescription()); |
||||
|
Assert.assertEquals("Tenant Profile Edge Test", tenantProfileUpdateMsg.getName()); |
||||
|
|
||||
|
loginTenantAdmin(); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue