Пример #1
0
  @Test
  public void checkTargetTime() {
    ArrayList<Map.Entry<Object, Class>> wanted = new ArrayList<>();
    wanted.add(new AbstractMap.SimpleEntry<>("levels", JSONArray.class));
    wanted.add(new AbstractMap.SimpleEntry<>(0, JSONObject.class));
    wanted.add(new AbstractMap.SimpleEntry<>("conditions", JSONArray.class));
    wanted.add(new AbstractMap.SimpleEntry<>(0, JSONObject.class));
    wanted.add(new AbstractMap.SimpleEntry<>("targetTime", JSONObject.class));

    Object t = JsonSearcher.lookFor(description, wanted);
    JSONObject targetTime = (JSONObject) t;

    assertEquals(WEEK_PERIOD.WEEK_DAYS.toString(), targetTime.getString("days"));
    assertEquals(DAY_MOMENT.MORNING.toString(), targetTime.getString("hours"));
  }
Пример #2
0
  @Test
  public void checkImprovement() {

    ArrayList<Map.Entry<Object, Class>> wanted = new ArrayList<>();
    wanted.add(new AbstractMap.SimpleEntry<>("levels", JSONArray.class));
    wanted.add(new AbstractMap.SimpleEntry<>(0, JSONObject.class));
    wanted.add(new AbstractMap.SimpleEntry<>("conditions", JSONArray.class));
    wanted.add(new AbstractMap.SimpleEntry<>(1, JSONObject.class));

    Object i = JsonSearcher.lookFor(description, wanted);
    JSONObject improvement = (JSONObject) i;

    assertEquals(IMPROVEMENT_TYPE.INCREASE.toString(), improvement.getString("improvementType"));
    assertEquals(LAST_MONTH.toString(), improvement.getString("referencePeriod"));
    assertEquals("SENSOR", improvement.getString("symbolicName"));
    assertEquals(50, improvement.getInt("threshold"));
  }
Пример #3
0
  @Test
  public void checkOperands() {

    ArrayList<Map.Entry<Object, Class>> wanted = new ArrayList<>();
    wanted.add(new AbstractMap.SimpleEntry<>("levels", JSONArray.class));
    wanted.add(new AbstractMap.SimpleEntry<>(0, JSONObject.class));
    wanted.add(new AbstractMap.SimpleEntry<>("conditions", JSONArray.class));
    wanted.add(new AbstractMap.SimpleEntry<>(0, JSONObject.class));
    wanted.add(new AbstractMap.SimpleEntry<>("expression", JSONObject.class));

    Object e = JsonSearcher.lookFor(description, wanted);
    JSONObject expression = (JSONObject) e;
    assertNotNull(expression.getJSONObject("comparator").getString("type"));
    assertNotNull(expression.getJSONObject("leftOperand"));
    assertNotNull(expression.getJSONObject("leftOperand").getString("symbolicName"));
    assertNotNull(expression.getJSONObject("rightOperand"));
    assertNotNull(expression.getJSONObject("rightOperand").getInt("value"));
  }