public void testParseAndCreateSlotInvalidArgs()

in DeliveryApi/ApiHandlers/tst/com/ilmlf/delivery/api/handlers/CreateSlotsTest.java [116:167]


  public void testParseAndCreateSlotInvalidArgs() {
    try {
      // nothing json to parse
      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(new JSONObject(), "2"));

      // null inputs
      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(null, defaultDate, defaultDate), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, null, defaultDate), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, defaultDate, null), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, defaultDate, defaultDate), null));

      // empty string inputs
      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson("", defaultDate, defaultDate), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, "", defaultDate), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, defaultDate, ""), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, defaultDate, ""), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, defaultDate, defaultDate), ""));

      // invalid data-type input
      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson("s", defaultDate, defaultDate), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, "s", defaultDate), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, defaultDate, "s"), "2"));

      assertThrows(RuntimeException.class, () ->
          SlotParser.parseAndCreateSlot(constructSlotJson(2, defaultDate, defaultDate), "s"));

    } catch (Exception e) {
      fail(e);
    }
  }