@Test
  public void should_generate_unique_integers() {
    int numberCount = 10;
    NumberGenerator generator = new NumberGenerator();

    ArrayList<Integer> numberList = generator.generate1(numberCount);

    ImmutableSet<Integer> set = ImmutableSet.copyOf(numberList);
    assertThat(set.size(), is(numberList.size()));
  }
  @Test
  public void should_generate_random_integers() {
    int numberCount = 4;
    NumberGenerator generator = new NumberGenerator();

    ArrayList<Integer> numberList = generator.generate1(numberCount);

    assertThat(numberList.size(), is(numberCount));
    assertThat(numberList.get(0), instanceOf(Integer.class));
  }
 @Override
 public void update(NumberGenerator generator) {
   System.out.println("DigitObserver: " + generator.getNumber());
   try {
     Thread.sleep(100);
   } catch (InterruptedException e) {
   }
 }
  @Test
  public void the_return_string_should_be_random() {
    int generatedTimes = 5;
    Set<String> numbersSet = new HashSet<>();
    for (int i = 0; i < generatedTimes; i++) {
      numbersSet.add(numberGenerator.generate());
    }

    assertThat(numbersSet.size(), is(generatedTimes));
  }
  @Test
  public void the_return_string_should_have_different_diggits() {
    String generated = numberGenerator.generate();
    Set<Character> numberSet = new HashSet<>();
    for (int i = 0; i < generated.length(); i++) {
      numberSet.add(generated.charAt(i));
    }

    assertThat(numberSet.size(), is(4));
  }
  @Test
  public void the_return_string_should_be_number() throws NumberFormatException {
    String generated = numberGenerator.generate();

    try {
      Integer.parseInt(generated);
    } catch (NumberFormatException e) {
      fail("Not a number");
    }
  }
  public void update(NumberGenerator generator) {
    System.out.println("GraphObserver");
    int count = generator.getNumber();
    for (int i = 0; i < count; i++) {
      System.out.print("*");
    }
    System.out.println("");
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {

    }
  }
  private void for_loop() {
    VarSymbol v = null, tempVar = null;
    FuncSymbol f = null, tempFunc = null;
    int index =
        input.indexOf(
            words.get(wordLoc)); // Index in input string at which the word was encountered
    String expString = "";
    index += (words.get(wordLoc).length() + 1);
    String str = input.substring(index); // Further processing will be done on this string
    tokens = str.split("[ ]+");
    index = 0;
    boolean flag = false;
    String expression = null;
    String tempStr = null;
    String loopCounter = "";

    while (true) {
      if ((v = Controller.varSym.searchSymbol(tokens[tIndex]))
          != null) /*|| (f = Controller.funSym.searchSymbol(tokens[tIndex])) != null*/ {
        loopCounter = v.getVarName(); // Holds the loopCounter variable
        expString = searchExpression();
        expression = exp.generateExpression(expString);
        tempVar = v;
      } else if (tokens[tIndex].equalsIgnoreCase("to")) { // If next token is not an operator
        loopParams[0] = expression;
        tIndex++;
        int tempNum = NumberGenerator.stringToNum(tokens[tIndex]);
        // if((tempStr = String.valueOf(toNumber(tokens[tIndex++])))){			// TODO Method 'toNumber()'
        // to be added later
        if (String.valueOf(tempNum) != null) {
          condition = tempStr;
          loopParams[1] = loopCounter + "<" + condition;
        } else if ((v = Controller.varSym.searchSymbol(tokens[tIndex])) != null
            || (Controller.funSym.searchSymbol(tokens[tIndex]) != null)) {
          tempStr = searchExpression();
          String tempString = exp.generateExpression(tempStr);
          int len = v.getVarName().length();
          if (tempString.startsWith(loopCounter) && tempString.charAt(len) == '=') {
            condition = tempString.substring(len + 1);
            loopParams[1] = loopCounter + "<" + condition;
          } else {
            condition = tempString;
            loopParams[1] = condition;
          }
        }
      } else if (tokens[tIndex].equalsIgnoreCase("increment")
          || (tokens[tIndex] + tokens[tIndex + 1]).equalsIgnoreCase("plusplus")
          || tokens[tIndex].equalsIgnoreCase("postincrement")
          || tokens[tIndex].equalsIgnoreCase("preincrement")) {
        expression = exp.generateExpression((str.substring(str.indexOf(tokens[tIndex]))));
        loopParams[2] = expression;
        break;
      } else if (tokens[tIndex].equalsIgnoreCase("decrement")
          || (tokens[tIndex] + tokens[tIndex + 1]).equalsIgnoreCase("minus minus")
          || tokens[tIndex].equalsIgnoreCase("postdecrement")
          || tokens[tIndex].equalsIgnoreCase("predecrement")) {
        expression = exp.generateExpression((str.substring(str.indexOf(tokens[tIndex]))));
        loopParams[2] = expression;
        break;
      }
      /*if(searchOperator(tIndex) != -1){
      	//TODO Index variable missing error to be handled
      }*/
      /*
      if(token is number){
      	number handling logic.
      	e.g : for loop 0 to 100.
      }
      */
      if ((tIndex) == tokens.length) {
        break;
      }
    }
    if (loopParams[2] == null) {
      loopParams[2] = loopCounter + "++";
    }
    code.setCodeText("for(" + loopParams[0] + ";" + loopParams[1] + ";" + loopParams[2] + ")");
    code.setErrCode(IErrorCodes.SUCCESS);
    code.setErrParam(null);
  }
  @Test
  public void the_return_string_length_should_be_4() {
    String generated = numberGenerator.generate();

    assertThat(generated.length(), is(4));
  }
 public Book createBook(String title, Float price, String description) {
   Book book = new Book(title, price, description);
   book.setNumber(numberGenerator.generateNumber());
   return book;
 }