public MqttProperty getProperty(int propertyId) {
        if (propertyId == MqttPropertyType.USER_PROPERTY.value) {
            //special handling to keep compatibility with earlier versions
            List<UserProperty> userProperties = this.userProperties;
            if (userProperties == null) {
                return null;
            }
            return UserProperties.fromUserPropertyCollection(userProperties);
        }
        if (propertyId == MqttPropertyType.SUBSCRIPTION_IDENTIFIER.value) {
            List<IntegerProperty> subscriptionIds = this.subscriptionIds;
            if (subscriptionIds == null || subscriptionIds.isEmpty()) {
                return null;
            }
            return subscriptionIds.get(0);
        }
        IntObjectHashMap<MqttProperty> props = this.props;
        return props == null ? null : props.get(propertyId);
    }
@Test
    public void testGetProperty() {
        MqttProperties props = createSampleProperties();

        assertEquals(
                "text/plain",
                ((MqttProperties.StringProperty) props.getProperty(CONTENT_TYPE.value())).value);
        assertEquals(
                10,
                ((MqttProperties.IntegerProperty) props.getProperty(SUBSCRIPTION_IDENTIFIER.value())).value.intValue());

        List<MqttProperties.StringPair> expectedUserProps = new ArrayList<MqttProperties.StringPair>();
        expectedUserProps.add(new MqttProperties.StringPair("isSecret", "true"));
        expectedUserProps.add(new MqttProperties.StringPair("tag", "firstTag"));
        expectedUserProps.add(new MqttProperties.StringPair("tag", "secondTag"));
        List<MqttProperties.StringPair> actualUserProps =
                ((MqttProperties.UserProperties) props.getProperty(USER_PROPERTY.value())).value;
        assertEquals(expectedUserProps, actualUserProps);
    }