コード例 #1
0
  @Test
  public void getCreneauxByIdAtelier() throws SQLException, IOException, ClassNotFoundException {

    BddUtilisateur.ajout("*****@*****.**", "labri");
    BddLabo.ajout(1, "Labri");
    BddAtelier.ajoutAtelier(
        1,
        "A la poursuite d'ennemis invisibles",
        "Sciences de la vie ",
        "Campus Carreire (Hôpital Pellegrin)",
        "Labo MFP",
        "",
        "",
        "",
        "");

    Map<Integer, Creneau> creneaux = new HashMap<Integer, Creneau>();

    // Test : récupération d'un objet null
    creneaux = BddCreneau.getCreneauxByIdAtelier(1);
    assertEquals(creneaux.size(), 0);

    // Insertion
    int idAtelier = 1;
    String jour = "2015-12-23";
    String heure = "21:00";
    int capacite = 20;
    BddCreneau.ajoutCreneau(idAtelier, jour, heure, capacite);

    // Test : récupération de creneaux
    creneaux = BddCreneau.getCreneauxByIdAtelier(idAtelier);
    assertEquals(creneaux.size(), 1);
  }
コード例 #2
0
  @Test
  public void testAjoutCreneau() throws SQLException, IOException, ClassNotFoundException {
    Connection connection = BddConnecteur.getConnection();

    BddUtilisateur.ajout("*****@*****.**", "labri");
    BddLabo.ajout(1, "Labri");
    BddAtelier.ajoutAtelier(
        1,
        "A la poursuite d'ennemis invisibles",
        "Sciences de la vie ",
        "Campus Carreire (Hôpital Pellegrin)",
        "Labo MFP",
        "",
        "",
        "",
        "");

    // Insertion
    int idAtelier = 1;
    String jour = "2015-12-23";
    String heure = "13:00";
    int capacite = 20;
    BddCreneau.ajoutCreneau(1, jour, heure, capacite);

    // Vérification
    String sql = "SELECT * FROM Creneau WHERE idAtelier='" + idAtelier + "'";
    Statement statement = connection.createStatement();
    ResultSet rs = statement.executeQuery(sql);

    int count = 0;
    Date jourRecup;
    Time heureRecup;
    int capaciteRecup = 0;

    while (rs.next()) {
      jourRecup = rs.getDate("jour");
      heureRecup = rs.getTime("heure");
      capaciteRecup = rs.getInt("capacite");
      count++;
    }

    assertEquals(count, 1);
    // assertEquals(jourRecup, jour);
    // assertEquals(heureRecup, heure);
    assertEquals(capaciteRecup, capacite);

    // Fermeture
    rs.close();
    statement.close();
    connection.close();
  }
コード例 #3
0
  @Test
  public void testSupprCreneauxByIdAtelier()
      throws SQLException, IOException, ClassNotFoundException {
    Connection connection = BddConnecteur.getConnection();

    BddUtilisateur.ajout("*****@*****.**", "labri");
    BddLabo.ajout(1, "Labri");
    BddAtelier.ajoutAtelier(
        1,
        "A la poursuite d'ennemis invisibles",
        "Sciences de la vie ",
        "Campus Carreire (Hôpital Pellegrin)",
        "Labo MFP",
        "",
        "",
        "",
        "");

    // Insertion
    int idAtelier = 1;
    String jour = "2015-12-23";
    String heure = "13:00";
    int oldCapacite = 20;
    int newCapacite = 40;
    BddCreneau.ajoutCreneau(1, jour, heure, oldCapacite);

    // Suppression
    BddCreneau.supprCreneauxByIdAtelier(1);

    // Vérification
    String sql = "SELECT * FROM Creneau WHERE idAtelier='" + idAtelier + "'";
    Statement statement = connection.createStatement();
    ResultSet rs = statement.executeQuery(sql);

    int count = 0;

    while (rs.next()) {
      count++;
    }

    assertEquals(count, 0);

    // Fermeture
    rs.close();
    statement.close();
    connection.close();
  }
コード例 #4
0
  @Test
  public void testGetAtelierByIdCreneau() throws SQLException, IOException, ClassNotFoundException {

    BddUtilisateur.ajout("*****@*****.**", "labri");
    BddLabo.ajout(1, "Labri");
    BddAtelier.ajoutAtelier(
        1,
        "A la poursuite d'ennemis invisibles",
        "Sciences de la vie ",
        "Campus Carreire (Hôpital Pellegrin)",
        "Labo MFP",
        "",
        "",
        "",
        "");
    BddAtelier.ajoutAtelier(
        1,
        "A la poursuite d'ennemis invisibles",
        "Sciences de la vie ",
        "Campus Carreire (Hôpital Pellegrin)",
        "Labo MFP",
        "",
        "",
        "",
        "");

    // Insertion
    int idAtelier = 1;
    String jour = "2015-12-23";
    String heure = "13:00";
    int capacite = 20;
    BddCreneau.ajoutCreneau(1, jour, heure, capacite);
    BddCreneau.ajoutCreneau(1, jour, heure, capacite);
    BddCreneau.ajoutCreneau(2, jour, heure, capacite);

    Atelier atelier = BddCreneau.getAtelierByIdCreneau(1);
    assertEquals(atelier.getIdAtelier(), 1);

    atelier = BddCreneau.getAtelierByIdCreneau(3);
    assertEquals(atelier.getIdAtelier(), 2);
  }