In order to properly test if it is executed on a slave, it requires end-to-end tests (using JenkinsRule).

       

      The tests should as well integrate this tests back:

      @Test
      public void ifCheckedPerformOsCheck_shouldThrowException_withCorrectValue() throws Exception {
          initializeOperatingSystemOs("windows");
          try {
              healthAnalyzerCommon.ifCheckedPerformOsCheck(OperatingSystem.LINUX, true);
              fail();
          } catch (AbortException e) {
              assertEquals(e.getMessage(), String.format("Your operating system: %s is not %s.", "linux",
                      OperatingSystem.getOs()));
          }
      }
      
      @Test
      public void ifCheckedPerformOsCheck_doesNotThrowException() throws Exception {
          initializeOperatingSystemOs("windows");
          healthAnalyzerCommon.ifCheckedPerformOsCheck(OperatingSystem.WINDOWS, true);
      }
      
      @Test
      public void isCheckedPerformWindowsInstallationCheck_throwsCorrectExceptionValue() throws Exception {
          if (OperatingSystem.IS_WINDOWS) {
              try {
                  healthAnalyzerCommon.isRegistryExist(NON_EXISTING_REGISTRY);
                  fail();
              } catch (AbortException e) {
                  assertEquals(e.getMessage(), DUMMY_PRODUCT_NAME + " is not installed. Please install it first.");
              }
          }
      }
      

          [JENKINS-54435] Add tests to HealthAnalyzerCommon

          Daniel Gront created issue -
          Daniel Gront made changes -
          Description Original: In order to properly test if it is executed on a slave, it requires end-to-end tests (using JenkinsRule).

           

          The tests should as well integrate this tests back:
          {code:java}
          @Test
          public void ifCheckedPerformOsCheck_shouldThrowException_withCorrectValue() throws Exception {
              initializeOperatingSystemOs("windows");
              try {
                  healthAnalyzerCommon.ifCheckedPerformOsCheck(OperatingSystem.LINUX, true);
                  fail();
              } catch (AbortException e) {
                  assertEquals(e.getMessage(), String.format("Your operating system: %s is not %s.", "linux",
                          OperatingSystem.getOs()));
              }
          }

          @Test
          public void ifCheckedPerformOsCheck_doesNotThrowException() throws Exception {
              initializeOperatingSystemOs("windows");
              healthAnalyzerCommon.ifCheckedPerformOsCheck(OperatingSystem.WINDOWS, true);
          }
          {code}
          New: In order to properly test if it is executed on a slave, it requires end-to-end tests (using JenkinsRule).

           

          The tests should as well integrate this tests back:
          {code:java}
          @Test
          public void ifCheckedPerformOsCheck_shouldThrowException_withCorrectValue() throws Exception {
              initializeOperatingSystemOs("windows");
              try {
                  healthAnalyzerCommon.ifCheckedPerformOsCheck(OperatingSystem.LINUX, true);
                  fail();
              } catch (AbortException e) {
                  assertEquals(e.getMessage(), String.format("Your operating system: %s is not %s.", "linux",
                          OperatingSystem.getOs()));
              }
          }

          @Test
          public void ifCheckedPerformOsCheck_doesNotThrowException() throws Exception {
              initializeOperatingSystemOs("windows");
              healthAnalyzerCommon.ifCheckedPerformOsCheck(OperatingSystem.WINDOWS, true);
          }

          @Test
          public void isCheckedPerformWindowsInstallationCheck_throwsCorrectExceptionValue() throws Exception {
              if (OperatingSystem.IS_WINDOWS) {
                  try {
                      healthAnalyzerCommon.isRegistryExist(NON_EXISTING_REGISTRY);
                      fail();
                  } catch (AbortException e) {
                      assertEquals(e.getMessage(), DUMMY_PRODUCT_NAME + " is not installed. Please install it first.");
                  }
              }
          }
          {code}
          Daniel Gront made changes -
          Labels New: Infrastructure

            gront Daniel Gront
            gront Daniel Gront
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: