public static void update(@NonNull SystemState systemState, @NonNull ConfigMap configMap) {
        Map<String, String> data = configMap.getData();
        if (data == null) {
            data = new LinkedHashMap<>();
            configMap.setData(data);
        }
        JsonNode modifiedJson = JsonUtils.mapper()
            .convertValue(systemState, JsonNode.class);
        // original
        JsonNode sourceJson =
            JsonUtils.jsonToObject(data.getOrDefault(GROUP, emptyJsonObject()), JsonNode.class);
        try {
            // patch
            JsonMergePatch jsonMergePatch = JsonMergePatch.fromJson(modifiedJson);
            // apply patch to original
            JsonNode patchedNode = jsonMergePatch.apply(sourceJson);
            data.put(GROUP, JsonUtils.objectToJson(patchedNode));
        } catch (JsonPatchException e) {
            throw new JsonParseException(e);
        }
    }
@Test
    void update() {
        SystemState newSystemState = new SystemState();
        newSystemState.setIsSetup(true);

        ConfigMap configMap = new ConfigMap();
        SystemState.update(newSystemState, configMap);
        assertThat(configMap.getData().get(SystemState.GROUP)).isEqualTo("{\"isSetup\":true}");

        var data = new LinkedHashMap<String, String>();
        configMap.setData(data);
        data.put(SystemState.GROUP, "{\"isSetup\":false}");
        SystemState.update(newSystemState, configMap);
        assertThat(configMap.getData().get(SystemState.GROUP)).isEqualTo("{\"isSetup\":true}");

        data.clear();
        data.put(SystemState.GROUP, "{\"isSetup\":true, \"foo\":\"bar\"}");
        newSystemState.setIsSetup(false);
        SystemState.update(newSystemState, configMap);
        assertThat(configMap.getData().get(SystemState.GROUP))
            .isEqualTo("{\"isSetup\":false,\"foo\":\"bar\"}");
    }