]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12364 - SonarQube analysis fixes
authorJacek <jacek.poreda@sonarsource.com>
Tue, 6 Aug 2019 15:40:20 +0000 (17:40 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 24 Sep 2019 18:21:13 +0000 (20:21 +0200)
server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoTest.java

index 43019062bc40cdf125905bfa53016e00c5962519..2f39a2fb03d2ac45347010aa0b958cef30ea74bc 100644 (file)
@@ -49,6 +49,37 @@ public class BranchDtoTest {
     assertThat(underTest.isMain()).isFalse();
   }
 
+  @Test
+  public void verify_equals() {
+    underTest.setUuid("U1");
+    underTest.setProjectUuid("U2");
+    underTest.setKey("K1");
+    underTest.setBranchType(BranchType.LONG);
+    underTest.setMergeBranchUuid("U3");
+
+    assertThat(underTest.toString()).isEqualTo("BranchDto{uuid='U1', " +
+      "projectUuid='U2', kee='K1', keyType=null, branchType=LONG, mergeBranchUuid='U3'}");
+  }
+
+  @Test
+  public void verify_toString() {
+    underTest.setUuid("U1");
+    underTest.setProjectUuid("U2");
+    underTest.setKey("K1");
+    underTest.setBranchType(BranchType.LONG);
+    underTest.setMergeBranchUuid("U3");
+
+    BranchDto toCompare = new BranchDto();
+
+    toCompare.setUuid("U1");
+    toCompare.setProjectUuid("U2");
+    toCompare.setKey("K1");
+    toCompare.setBranchType(BranchType.LONG);
+    toCompare.setMergeBranchUuid("U3");
+
+    assertThat(underTest).isEqualTo(toCompare);
+  }
+
   @Test
   public void encode_and_decode_pull_request_data() {
     String branch = "feature/pr1";
index 4b238b9eef94b9f502e3887bbd1eb5fc192cd9a1..1b5009af1a9f6c04e218ea5e29968b6c87446bfa 100644 (file)
@@ -252,6 +252,21 @@ public class NewCodePeriodDaoTest {
     assertThat(exists).isTrue();
   }
 
+  @Test
+  public void delete_by_project_uuid_and_branch_uuid() {
+    when(uuidFactory.create()).thenReturn(NEW_CODE_PERIOD_UUID);
+
+    underTest.insert(dbSession, new NewCodePeriodDto()
+      .setProjectUuid("proj-uuid")
+      .setBranchUuid("branch-uuid")
+      .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+      .setValue("analysis-uuid"));
+
+    underTest.deleteByProjectUuidAndBranchUuid(dbSession, "proj-uuid", "branch-uuid");
+    db.commit();
+    assertNewCodePeriodRowCount(0);
+  }
+
   @Test
   public void exists_by_project_analysis_is_false() {
     boolean exists = underTest.existsByProjectAnalysisUuid(dbSession, "analysis-uuid");