Package classes

Examples of classes.Category


import classes.PointR;

public class CategoryTest {
  @Test
  public void testCtorForNameMemberInit() {
    Category c = new Category("c1");
    if (!c.getName().equals("c1")) {
      fail("Category constructor Name value incorrect");
    }
  }
View Full Code Here


    }
  }
 
  @Test
  public void testCtorForNameGestureMember() {
    Category c = null;
    try {
      c = new Category("circle", new Gesture("circle1",
          new ArrayList<PointR>()));
    }
    catch (Exception e) {
      fail("Category constructor Name value incorrect, Exception Details: "
          + e.getMessage());
    }
    try {
      if (c != null && !c.getName().equals("circle")
          && c.getExamples() != 1
          && !c.getGesture(0).getName().equals("circle1")) {
        fail("Category constructor Name value incorrect");
      }
    }
    catch (Exception e) {
      fail("Category constructor Name value incorrect, Exception Details: "
View Full Code Here

    }
  }
 
  @Test
  public void testName() {
    Category c = new Category("test");
    if (!c.getName().equals("test")) {
      fail("Name not retrived correctly");
    }
  }
View Full Code Here

    }
  }
 
  @Test
  public void testGetGesttureWithNullPrototypes() {
    Category c = new Category("c");
    try {
      c.getGesture(5);
    }
    catch (Exception e) {
      if (e.getMessage().indexOf("prototypes not initialised") != -1) {
        return;
      }
View Full Code Here

    ArrayList<Gesture> prototypes = new ArrayList<Gesture>();
    for (int i = 0; i < 5; i++) {
      Gesture g = new Gesture("test" + i, new ArrayList<PointR>());
      prototypes.add(g);
    }
    Category c = null;
    try {
      c = new Category("test", prototypes);
    }
    catch (Exception e1) {
      fail("exception in initialising a category with prototypes");
    }
    try {
      if (!c.getGesture(4).getName().equals("test4"))
        fail("get gesture not working properly");
    }
    catch (Exception e) {
      fail("get gesture not working properly");
    }
View Full Code Here

    ArrayList<String> data = new ArrayList<String>(5);
    for (@SuppressWarnings("unused")
    String s : data) {
      s = "t";
    }
    Category c = null;
    try {
      c = new Category("test", data);
    }
    catch (Exception e) {
      if (e.getMessage().indexOf("Prototypes name") != -1) {
        return;
      }
    }
    if (!(c.getExamples() == data.size())) {
      fail("Example() not working properly");
    }
  }
View Full Code Here

    }
  }
 
  @Test
  public void testAddExample() {
    Category c = new Category("test");
    try {
      c.addExample(new Gesture("testKIKI", null));
    }
    catch (Exception e) {
      if (e.getMessage().indexOf("Prototype name") != -1) {
        return;
      }
      else
        fail("error in adding examples." + e.getMessage());
    }
    if (c.getExamples() != 1) {
      fail("error in adding examples");
    }
  }
View Full Code Here

    ArrayList<Gesture> prototypes = new ArrayList<Gesture>();
    for (int i = 0; i < 5; i++) {
      Gesture g = new Gesture("test" + i, new ArrayList<PointR>());
      prototypes.add(g);
    }
    Category c = null;
    try {
      c = new Category("test", prototypes);
    }
    catch (Exception e1) {
      fail("exception in initialising a category with prototypes");
    }
    try {
      c.addExample(new Gesture("test5", null));
    }
    catch (Exception e) {
      if (e.getMessage().indexOf("Prototype name") != -1) {
        return;
      }
      else
        fail("error in adding examples." + e.getMessage());
    }
    if (c.getExamples() != 6) {
      fail("error in adding examples");
    }
    try {
      c.addExample(new Gesture("test5", null));
    }
    catch (Exception e) {
      if (e.getMessage().indexOf("Prototype name") != -1) {
        return;
      }
      else
        fail("error in adding examples." + e.getMessage());
    }
    if (c.getExamples() != 6) {
      fail("error in adding examples");
    }
  }
View Full Code Here

    }
  }
 
  @Test
  public void testCtorForNameAndObjectMembersInit() {
    Category c = null;
    try {
      Gesture g = new Gesture("c1", null);
      c = new Category("c1", g);
    }
    catch (Exception e) {
      if (e.getMessage().toLowerCase().indexOf("prototype name") != -1) {
        return;// it is a valid system generated exception for not
            // initializing the prototypes
      }
      else
        fail("failed to add example, " + e.getMessage());
    }
    if (c == null || c.getExamples() == 0) {
      fail("no examples added in constructor");
    }
    else if (c.getExamples() > 1) {
      fail("garbage values for examples inside Category");
    }
  }
View Full Code Here

    }
  }
 
  @Test
  public void testCtorForGenericParamsInit() {
    Category c = null;
    ArrayList<String> data = new ArrayList<String>(5);
    for (@SuppressWarnings("unused")
    String s : data) {
      s = "t";
    }
    try {
      c = new Category("test", data);
      for (int i = 0; i < 5; i++) {
        try {
          if (c.getGesture(i) == null) {
            fail("Examples not added properly as Gestures in Contructor with generic params");
            break;
          }
          else if (!c.getGesture(i).getClass().equals(Gesture.class)) {
            fail("Examples not added properly as Gestures in Contructor with generic params");
            break;
          }
        }
        catch (Exception e) {
View Full Code Here

TOP

Related Classes of classes.Category

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.