@Override
    public MastershipRole getRole(NetworkId networkId, NodeId nodeId, DeviceId deviceId) {
        Map<DeviceId, NodeId> masterMap = getMasterMap(networkId);
        Map<DeviceId, List<NodeId>> backups = getBackups(networkId);

        //just query
        NodeId current = masterMap.get(deviceId);
        MastershipRole role;

        if (current != null && current.equals(nodeId)) {
            return MastershipRole.MASTER;
        }

        if (backups.getOrDefault(deviceId, Collections.emptyList()).contains(nodeId)) {
            role = MastershipRole.STANDBY;
        } else {
            role = MastershipRole.NONE;
        }
        return role;
    }
@Test
    public void getRole() {
        //special case, no backup or master
        put(VNID1, VDID1, N1, false, false);
        assertEquals("wrong role", NONE, sms.getRole(VNID1, N1, VDID1));

        //backup exists but we aren't mapped
        put(VNID1, VDID2, N1, false, true);
        assertEquals("wrong role", STANDBY, sms.getRole(VNID1, N1, VDID2));

        //N2 is master
        put(VNID1, VDID3, N2, true, true);
        assertEquals("wrong role", MASTER, sms.getRole(VNID1, N2, VDID3));

        //N2 is master but N1 is only in backups set
        put(VNID1, VDID4, N1, false, true);
        put(VNID1, VDID4, N2, true, false);
        assertEquals("wrong role", STANDBY, sms.getRole(VNID1, N1, VDID4));
    }