test_class.declarator: dataSource
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private DataSource dataSource;
test_class.type: DataSource
test_class.var_name: dataSource
test_class.declarator: healthChecker = new DataSourceHealthChecker()
test_class.modifier: private
test_class.original_string: private DataSourceHealthChecker healthChecker = new DataSourceHealthChecker();
test_class.type: DataSourceHealthChecker
test_class.var_name: healthChecker
test_class.file: infrastructure/metrics-jsr340/src/test/java/de/qaware/oss/metrics/jsr340/DataSourceHealthCheckerTest.java
test_class.identifier: DataSourceHealthCheckerTest
test_case.body: @Test
      public void checkUnhealthyConnectionInvalid() throws Exception {
          Connection connectionMock = Mockito.mock(Connection.class);
          when(connectionMock.isValid(anyInt())).thenReturn(false);
          when(dataSource.getConnection()).thenReturn(connectionMock);
          assertThat(healthChecker.check(dataSource).isHealthy(), is(false));
      }
test_case.class_method_signature: DataSourceHealthCheckerTest.checkUnhealthyConnectionInvalid()
test_case.full_signature: @Test public void checkUnhealthyConnectionInvalid()
test_case.identifier: checkUnhealthyConnectionInvalid
test_case.invocations: mock thenReturn when isValid anyInt thenReturn when getConnection assertThat isHealthy check is
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void checkUnhealthyConnectionInvalid()
focal_class.file: infrastructure/metrics-jsr340/src/main/java/de/qaware/oss/metrics/jsr340/DataSourceHealthChecker.java
focal_class.identifier: DataSourceHealthChecker
focal_class.class_method_signature: DataSourceHealthChecker.check(DataSource dataSource)
focal_class.full_signature: public Result check(DataSource dataSource)
focal_class.identifier: check
focal_class.modifiers: public
focal_class.parameters: (DataSource dataSource)
focal_class.return: Result
focal_class.signature: Result check(DataSource dataSource)
focal_method.body: public Result check(DataSource dataSource) {
          try (Connection connection = dataSource.getConnection()) {
              if (connection == null) {
                  return Result.unhealthy("No database connection could be established");
              }
              if (!connection.isValid(1)) {
                  return Result.unhealthy("Connection is not valid");
              }
          } catch (SQLException e) {
              return Result.unhealthy(e);
          }
          return Result.healthy();
      }
focal_method.class_method_signature: DataSourceHealthChecker.check(DataSource dataSource)
focal_method.full_signature: public Result check(DataSource dataSource)
focal_method.identifier: check
focal_method.invocations: getConnection unhealthy isValid unhealthy unhealthy healthy
focal_method.modifiers: public
focal_method.parameters: (DataSource dataSource)
focal_method.return: Result
focal_method.signature: Result check(DataSource dataSource)