@Override
    public List<TaskProperty> getPropertiesForDisplay() {
        ArrayList<TaskProperty> taskProperties = new ArrayList<>();
        if (PluggableTaskConfigStore.store().hasPreferenceFor(pluginConfiguration.getId())) {
            TaskPreference preference = taskPreference();
            List<? extends Property> propertyDefinitions = preference.getConfig().list();
            for (Property propertyDefinition : propertyDefinitions) {
                ConfigurationProperty configuredProperty = configuration.getProperty(propertyDefinition.getKey());
                if (configuredProperty == null) continue;
                taskProperties.add(new TaskProperty(propertyDefinition.getOption(Property.DISPLAY_NAME), configuredProperty.getDisplayValue(), configuredProperty.getConfigKeyName()));
            }
            return taskProperties;
        }

        for (ConfigurationProperty property : configuration) {
            taskProperties.add(new TaskProperty(property.getConfigKeyName(), property.getDisplayValue()));
        }
        return taskProperties;
    }
@Test
    public void shouldGetOnlyConfiguredPropertiesIfACertainPropertyDefinedByPluginIsNotConfiguredByUser() throws Exception {
        Task taskDetails = mock(Task.class);
        TaskConfig taskConfig = new TaskConfig();
        addProperty(taskConfig, "KEY2", "Key 2", 1);
        addProperty(taskConfig, "KEY1", "Key 1", 0);
        addProperty(taskConfig, "KEY3", "Key 3", 2);
        when(taskDetails.config()).thenReturn(taskConfig);
        when(taskDetails.view()).thenReturn(mock(TaskView.class));

        String pluginId = "plugin_with_all_details";
        PluggableTaskConfigStore.store().setPreferenceFor(pluginId, new TaskPreference(taskDetails));

        Configuration configuration = new Configuration(
                ConfigurationPropertyMother.create("KEY1", false, "value1"),
                ConfigurationPropertyMother.create("KEY2", false, "value2")
        );

        PluggableTask task = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);

        List<TaskProperty> propertiesForDisplay = task.getPropertiesForDisplay();

        assertThat(propertiesForDisplay.size(), is(2));
        assertProperty(propertiesForDisplay.get(0), "Key 1", "value1", "key1");
        assertProperty(propertiesForDisplay.get(1), "Key 2", "value2", "key2");
    }