private LifecycleInfo addLifecycle(String name) throws Exception {

    LifecycleInfo origLife = new LifecycleInfo();
    RichTextInfo rti = new RichTextInfo();
    rti.setFormatted("<b>Formatted</b> lifecycle for testing purposes");
    rti.setPlain("Plain lifecycle for testing purposes");
    origLife.setDescr(rti);
    origLife.setKey(name);
    origLife.setName("TEST_NAME");
    origLife.setRefObjectUri("TEST_URI");
    AttributeInfo attr = new AttributeInfo();
    attr.setKey("attribute.key");
    attr.setValue("attribute value");
    origLife.getAttributes().add(attr);

    return stateService.createLifecycle(origLife.getKey(), origLife, callContext);
  }
  private StateInfo addState(LifecycleInfo lifecycleInfo, String state, boolean isInitialState)
      throws Exception {

    StateInfo orig = new StateInfo();
    orig.setKey(state);
    orig.setLifecycleKey(lifecycleInfo.getKey());
    RichTextInfo rti = new RichTextInfo();
    rti.setFormatted("<b>Formatted again</b> state for testing purposes");
    rti.setPlain("Plain state again for testing purposes");
    orig.setDescr(rti);
    orig.setName("Testing state");
    Date effDate = new Date();
    orig.setEffectiveDate(effDate);
    Calendar cal = Calendar.getInstance();
    cal.set(2022, 8, 23);
    orig.setExpirationDate(cal.getTime());
    AttributeInfo attr = new AttributeInfo();
    attr.setKey("attribute.key");
    attr.setValue("attribute value");
    orig.getAttributes().add(attr);
    orig.setIsInitialState(isInitialState);

    return stateService.createState(orig.getLifecycleKey(), orig.getKey(), orig, callContext);
  }