// ** ** ** ** ** ** **
  // ASSERTS
  // ** ** ** ** ** ** **
  public void asserts_create() {
    SSHCommandResult res;
    if (this.id == null) updateIDs();

    // asserts: activation_key list
    res = list(this.environment);
    Assert.assertTrue(
        res.getExitCode().intValue() == 0, "Check - return code (activation_key list)");
    String REGEXP_AK_LIST =
        ".*Id\\s*:\\s*\\d+.*Name\\s*:\\s*%s.*Environment Id\\s*:\\s*%s.*System Template Id\\s*:\\s*%s.*";

    String match_info =
        String.format(REGEXP_AK_LIST, this.name, this.environment_id, this.template_id)
            .replaceAll("\"", "");
    if (this.template_id == null) {
      match_info =
          String.format(REGEXP_AK_LIST, this.name, this.environment_id, "None")
              .replaceAll("\"", "");
    }
    Assert.assertTrue(
        KatelloCliTestScript.sgetOutput(res).replaceAll("\n", "").matches(match_info),
        String.format("Activation key [%s] should be found in the list", this.name));

    // asserts: activation_key info
    res = info();
    Assert.assertTrue(
        res.getExitCode().intValue() == 0, "Check - return code (activation_key info)");
    String REGEXP_AK_INFO =
        ".*Id\\s*:\\s*\\d+.*Name\\s*:\\s*%s.*Usage Limit\\s*:\\s*%s.*Environment Id\\s*:\\s*%s.*System Template Id\\s*:\\s*%s.*Pools\\s*:.*";
    match_info =
        String.format(
                REGEXP_AK_INFO,
                this.name,
                (this.limit != null ? this.limit : "unlimited"),
                this.environment_id,
                this.template_id)
            .replaceAll("\"", "");
    if (this.template_id == null) {
      match_info =
          String.format(
                  REGEXP_AK_INFO,
                  this.name,
                  (this.limit != null ? this.limit : "unlimited"),
                  this.environment_id,
                  "None")
              .replaceAll("\"", "");
    }
    Assert.assertTrue(
        KatelloCliTestScript.sgetOutput(res).replaceAll("\n", "").matches(match_info),
        String.format("Activation key [%s] should contain correct info", this.name));
  }
Exemple #2
0
  @Test(
      description =
          "Tests creating activation key by providing name got from i18n messages.properties.")
  public void test_createAKLocale() {
    String uid = KatelloUtils.getUniqueID();
    String akName = KatelloCliTestScript.getText("ak.name") + uid;
    SSHCommandResult res;

    KatelloActivationKey ak =
        new KatelloActivationKey(
            this.organization, this.env, akName, "Activation key to with localized name", null);
    res = ak.create();
    Assert.assertTrue(
        res.getExitCode().intValue() == 0, "Check - return code (activation_key create)");
  }