From e355b1927914aec7e22b4c3da98d9e75c48a57d5 Mon Sep 17 00:00:00 2001 From: Serhat Yenican <104850907+serhat-yenican-sonarsource@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:45:11 +0100 Subject: CODEFIX-192 Add ai code fix enablement to audit logs (#12238) --- .../sonar/db/audit/model/ProjectNewValueTest.java | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ProjectNewValueTest.java (limited to 'server/sonar-db-dao/src/test') diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ProjectNewValueTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ProjectNewValueTest.java new file mode 100644 index 00000000000..fa95e45897c --- /dev/null +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ProjectNewValueTest.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.audit.model; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.junit.jupiter.api.Test; +import org.sonar.db.project.ProjectDto; + +import static org.assertj.core.api.Assertions.assertThat; + +class ProjectNewValueTest { + + @Test + void toString_generatesValidJson() throws ParseException { + var project = new ProjectDto() + .setUuid("uuid") + .setName("name") + .setKey("key") + .setPrivate(true) + .setDescription("description") + .setQualifier("TRK") + .setAiCodeFixEnabled(true); + ProjectNewValue newValue = new ProjectNewValue(project); + + JSONObject jsonObject = (JSONObject) new JSONParser().parse(newValue.toString()); + + assertThat(jsonObject).hasSize(7); + } +} -- cgit v1.2.3