示例#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();
  }
示例#2
0
  @Before
  public void setUp() {
    TestHelper.signon(this);

    // Define connection to db - Lazy Connection
    MongoHelper.setDB("iCrossFit");

    // Clear db
    try {
      MongoHelper.getCollection("trainingClasses").drop();
    }
    // If  connection unsuccessful
    catch (Exception e) {
      System.out.println("Mongo DB is not running.  Please start and try again.");
      TestHelper.failed("Mongo DB is not running.  Please start and try again.");
    }

    // Create a training Class instance
    TrainingClass trainingClass = new TrainingClass();

    // Save initial training Class instance to db
    if (!MongoHelper.save(trainingClass, "trainingClasses")) {
      TestHelper.failed("Initial training Class Save failed.");
    }

    // Report status
    System.out.println(
        "Successfully saved initial training Class id = " + trainingClass.getId() + ".");
  }
示例#3
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();
  }
示例#4
0
  @Before
  public void setUp() {
    TestHelper.signon(this);

    // Connect to DB - Lazy
    MongoHelper.setDB("iCrossFit");

    // Clear out DB
    try {
      MongoHelper.getCollection("trainingClasses").drop();
    }
    // If not connected
    catch (Exception e) {
      System.out.println("Mongo DB is not running.  Please start and try again.");
      TestHelper.failed("Mongo DB is not running.  Please start and try again.");
    }
  }
示例#5
0
 @After
 public void tearDown() {
   TestHelper.signoff(this);
 }