// add key1 through user config, key2 through resource config, key3 through ideal state,
// resource type through resource config, rebalance mode through ideal state
ResourceId resourceId = ResourceId.from("resourceId");
UserConfig userConfig = new UserConfig(Scope.resource(resourceId));
userConfig.setSimpleField(KEY1, VALUE1);
ResourceConfiguration resourceConfig = new ResourceConfiguration(resourceId);
resourceConfig.setType(ResourceType.DATA);
resourceConfig.addNamespacedConfig(userConfig);
resourceConfig.getRecord().setSimpleField(KEY2, VALUE2);
IdealState idealState = new IdealState(resourceId);
idealState.setRebalanceMode(RebalanceMode.USER_DEFINED);
idealState.getRecord().setSimpleField(KEY3, VALUE3);
// should have key1, key2, and key3, not type or rebalance mode
UserConfig result = resourceConfig.getUserConfig();
idealState.updateUserConfig(result);
Assert.assertEquals(result.getSimpleField(KEY1), VALUE1);
Assert.assertEquals(result.getSimpleField(KEY2), VALUE2);
Assert.assertEquals(result.getSimpleField(KEY3), VALUE3);
Assert.assertNull(result.getSimpleField(ResourceConfiguration.Fields.TYPE.toString()));