content: /*
   * Copyright (c) 2023 Airbyte, Inc., all rights reserved.
   */
  package io.airbyte.integrations.destination.yellowbrick;
  
  import static org.junit.jupiter.api.Assertions.assertEquals;
  import static org.junit.jupiter.api.Assertions.assertTrue;
  
  import com.fasterxml.jackson.databind.JsonNode;
  import com.fasterxml.jackson.databind.node.ObjectNode;
  import io.airbyte.commons.io.IOs;
  import io.airbyte.commons.json.Jsons;
  import io.airbyte.protocol.models.v0.AirbyteConnectionStatus;
  import java.nio.file.Path;
  import org.junit.jupiter.api.Test;
  
  public class YellowbrickConnectionTest {
  
    private final JsonNode config = Jsons.deserialize(IOs.readFile(Path.of("secrets/config.json")));
    private final YellowbrickDestination destination = new YellowbrickDestination();
    private AirbyteConnectionStatus status;
  
    @Test
    void testCheckIncorrectPasswordFailure() throws Exception {
      ((ObjectNode) config).put("password", "fake");
      status = destination.check(config);
      assertEquals(AirbyteConnectionStatus.Status.FAILED, status.getStatus());
      assertTrue(status.getMessage().contains("State code: 28P01;"));
    }
  
    @Test
    public void testCheckIncorrectUsernameFailure() throws Exception {
      ((ObjectNode) config).put("username", "");
      status = destination.check(config);
      assertEquals(AirbyteConnectionStatus.Status.FAILED, status.getStatus());
      assertTrue(status.getMessage().contains("State code: 28000;"));
    }
  
    @Test
    public void testCheckIncorrectHostFailure() throws Exception {
      ((ObjectNode) config).put("host", "localhost2");
      status = destination.check(config);
      assertEquals(AirbyteConnectionStatus.Status.FAILED, status.getStatus());
      assertTrue(status.getMessage().contains("State code: 08001;"));
    }
  
    @Test
    public void testCheckIncorrectDataBaseFailure() throws Exception {
      ((ObjectNode) config).put("database", "wrongdatabase");
      status = destination.check(config);
      assertEquals(AirbyteConnectionStatus.Status.FAILED, status.getStatus());
      assertTrue(status.getMessage().contains("State code: 3D000;"));
    }
  
  }
  