Exemplo n.º 1
0
  // Create basic gym object and save it to the DB
  @Test
  public void test() {

    // Create New Gym entry
    TrainingClass trainingClass = new TrainingClass();

    // set vars
    trainingClass.setName("Zumba");
    trainingClass.setStartTime(new GregorianCalendar(2013, 6, 10, 8, 0).getTime());
    trainingClass.setEndTime(new GregorianCalendar(2013, 6, 10, 9, 0).getTime());
    trainingClass.setTrainer(new User());
    trainingClass.setLevel("Easy");
    trainingClass.setMaxCapacity(140);
    trainingClass.setWorkoutDetails(
        "Zumba combines Latin and International music with a fun and effective workout system");
    trainingClass.setPrice(95.00);
    trainingClass.setComments("Zumba Fitness is an exhilarating, effective, easy-to-follow ");
    trainingClass.setCanceled(false);
    trainingClass.setGymID(0);
    trainingClass.getUserIds().add(1);
    trainingClass.getUserIds().add(2);
    trainingClass.getUserIds().add(3);

    // Attempt Save
    if (!MongoHelper.save(trainingClass, "trainingClasses")) {
      TestHelper.failed("Save failed.");
    }

    // Print object and infomation
    System.out.println(trainingClass.toString());
    System.out.println("\nSuccessfully saved TrainingClass id = " + trainingClass.getId() + ".");

    // Pass test
    TestHelper.passed();
  }
Exemplo n.º 2
0
  // Delete initially created training Class instance from db
  @Test
  public void test() {
    // Create a new training Class instance template to match initial one
    TrainingClass trainingClass = new TrainingClass(0);

    // Attempt to delete
    if (!MongoHelper.delete(trainingClass, "trainingClasses")) {
      TestHelper.failed("Delete failed.");
    }

    // Report status
    System.out.println("\nSuccessfully deleted training Class id = " + trainingClass.getId() + ".");

    // Test passed
    TestHelper.passed();
  }