Browse Source
PartitionChangeMsg only carried the affected ServiceType, so a
consumer had no way to know which specific tenants (if any) a given
partition change actually affects versus all of them. Add an optional
affectedTenants set: null preserves today's meaning ("could affect
anyone, notify everyone"), a non-null set means only those tenants are
affected. Existing single-arg construction is unchanged and keeps
defaulting to null.
pull/15961/head
2 changed files with 67 additions and 2 deletions
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright © 2016-2026 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.common.msg.queue; |
|||
|
|||
import org.junit.jupiter.api.Test; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.msg.MsgType; |
|||
|
|||
import java.util.Set; |
|||
import java.util.UUID; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals; |
|||
import static org.junit.jupiter.api.Assertions.assertNull; |
|||
|
|||
public class PartitionChangeMsgTest { |
|||
|
|||
@Test |
|||
public void singleArgConstructor_defaultsAffectedTenantsToNull() { |
|||
PartitionChangeMsg msg = new PartitionChangeMsg(ServiceType.TB_RULE_ENGINE); |
|||
|
|||
assertEquals(ServiceType.TB_RULE_ENGINE, msg.getServiceType()); |
|||
assertNull(msg.getAffectedTenants()); |
|||
assertEquals(MsgType.PARTITION_CHANGE_MSG, msg.getMsgType()); |
|||
} |
|||
|
|||
@Test |
|||
public void twoArgConstructor_carriesAffectedTenants() { |
|||
TenantId tenant = new TenantId(UUID.randomUUID()); |
|||
PartitionChangeMsg msg = new PartitionChangeMsg(ServiceType.TB_RULE_ENGINE, Set.of(tenant)); |
|||
|
|||
assertEquals(ServiceType.TB_RULE_ENGINE, msg.getServiceType()); |
|||
assertEquals(Set.of(tenant), msg.getAffectedTenants()); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue