]> source.dussan.org Git - sonarqube.git/commitdiff
Update tests to use the ignore fields feature of JsonAssert
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 27 Aug 2015 15:04:38 +0000 (17:04 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 27 Aug 2015 15:04:38 +0000 (17:04 +0200)
server/sonar-server/src/main/resources/org/sonar/server/permission/ws/create_template-example.json
server/sonar-server/src/main/resources/org/sonar/server/permission/ws/update_template-example.json
server/sonar-server/src/test/java/org/sonar/server/permission/ws/CreateTemplateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/ws/UpdateTemplateActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/CreateTemplateActionTest/create_template.json [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/permission/ws/UpdateTemplateActionTest/update_template.json [deleted file]

index d27d52f9003695a7ae25c7dbfd3ade84fceb62ff..5a49450b905272490459c7c7a0d9653838251dee 100644 (file)
@@ -2,7 +2,7 @@
   "permissionTemplate": {
     "id": "af8cb8cc-1e78-4c4e-8c00-ee8e814009a5",
     "name": "Finance",
-    "description": "Permissions for financial related projects",
+    "description": "Permissions for financially related projects",
     "projectKeyPattern": ".*\\.finance\\..*",
     "createdAt": "2015-08-25T16:18:48+0200",
     "updatedAt": "2015-08-25T16:18:48+0200"
index d27d52f9003695a7ae25c7dbfd3ade84fceb62ff..3ef72119a12a44b4cb858722fb02185d52918e5b 100644 (file)
@@ -2,9 +2,9 @@
   "permissionTemplate": {
     "id": "af8cb8cc-1e78-4c4e-8c00-ee8e814009a5",
     "name": "Finance",
-    "description": "Permissions for financial related projects",
+    "description": "Permissions for financially related projects",
     "projectKeyPattern": ".*\\.finance\\..*",
-    "createdAt": "2015-08-25T16:18:48+0200",
+    "createdAt": "2001-09-09T03:46:40+0200",
     "updatedAt": "2015-08-25T16:18:48+0200"
   }
 }
index e4208eabc488b422ee664f4fe31dc327e51efeed..230c615bb5c3095b2bf2ad0d8f69c82d38a96ee5 100644 (file)
@@ -76,7 +76,9 @@ public class CreateTemplateActionTest {
   public void create_full_permission_template() {
     TestResponse result = newRequest("Finance", "Permissions for financially related projects", ".*\\.finance\\..*");
 
-    assertJson(result.getInput()).isSimilarTo(getClass().getResource("CreateTemplateActionTest/create_template.json"));
+    assertJson(result.getInput())
+      .ignoreFields("id")
+      .isSimilarTo(getClass().getResource("create_template-example.json"));
     PermissionTemplateDto finance = dbClient.permissionTemplateDao().selectByName(dbSession, "Finance");
     assertThat(finance.getName()).isEqualTo("Finance");
     assertThat(finance.getDescription()).isEqualTo("Permissions for financially related projects");
index 7cb9d82e3f1e61480d243ebc49adfd0dc07ad06c..45acf036bfdc5b0b3d7c4c60a9976e210ae2a967 100644 (file)
@@ -92,7 +92,9 @@ public class UpdateTemplateActionTest {
   public void update_all_permission_template_fields() {
     TestResponse result = newRequest(templateDto.getKee(), "Finance", "Permissions for financially related projects", ".*\\.finance\\..*");
 
-    assertJson(result.getInput()).isSimilarTo(getClass().getResource("UpdateTemplateActionTest/update_template.json"));
+    assertJson(result.getInput())
+      .ignoreFields("id")
+      .isSimilarTo(getClass().getResource("update_template-example.json"));
     PermissionTemplateDto finance = dbClient.permissionTemplateDao().selectByName(dbSession, "Finance");
     assertThat(finance.getName()).isEqualTo("Finance");
     assertThat(finance.getDescription()).isEqualTo("Permissions for financially related projects");
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/CreateTemplateActionTest/create_template.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/CreateTemplateActionTest/create_template.json
deleted file mode 100644 (file)
index 0d4c713..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-  "permissionTemplate": {
-    "name": "Finance",
-    "description": "Permissions for financially related projects",
-    "projectKeyPattern": ".*\\.finance\\..*",
-    "createdAt": "2015-08-25T16:18:48+0200",
-    "updatedAt": "2015-08-25T16:18:48+0200"
-  }
-}
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/UpdateTemplateActionTest/update_template.json b/server/sonar-server/src/test/resources/org/sonar/server/permission/ws/UpdateTemplateActionTest/update_template.json
deleted file mode 100644 (file)
index 1d0f4eb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-  "permissionTemplate": {
-    "name": "Finance",
-    "description": "Permissions for financially related projects",
-    "projectKeyPattern": ".*\\.finance\\..*",
-    "createdAt": "2001-09-09T03:46:40+0200",
-    "updatedAt": "2015-08-25T16:18:48+0200"
-  }
-}