コード例 #1
0
ファイル: _PmAssert.java プロジェクト: ulehnerhs/org.pm4j
 /**
  * Checks if each of the given PM's is not marked as changed.
  *
  * @param pms the PMs to check.
  */
 public static void assertNotChanged(PmObject... pms) {
   for (PmObject pm : pms) {
     if (pm.isPmValueChanged()) {
       fail(pm.getPmRelativeName() + " should not be in a changed state.");
     }
   }
 }
コード例 #2
0
ファイル: _PmAssert.java プロジェクト: ulehnerhs/org.pm4j
 /**
  * Checks if the given set of PMs is not enabled.
  *
  * @param pms the PMs to check.
  */
 public static void assertNotEnabled(PmObject... pms) {
   for (PmObject pm : pms) {
     if (pm.isPmEnabled()) {
       fail(pm.getPmRelativeName() + " should not be enabled.");
     }
   }
 }
コード例 #3
0
ファイル: _PmAssert.java プロジェクト: ulehnerhs/org.pm4j
 /**
  * Checks if the given set of PMs is not visible.
  *
  * @param pms the PMs to check.
  */
 public static void assertNotVisible(PmObject... pms) {
   for (PmObject pm : pms) {
     if (pm.isPmVisible()) {
       fail(pm.getPmRelativeName() + " should not be visible.");
     }
   }
 }
コード例 #4
0
ファイル: PmTableAssert.java プロジェクト: ulehnerhs/org.pm4j
 private static String getDisplayStringOfCell(PmBean<?> rowPm, String columnName) {
   PmObject cell = PmUtil.findChildPm(rowPm, columnName);
   if (cell == null) {
     throw new PmRuntimeException("Row cell for column name '" + columnName + "' not found.");
   }
   if (cell instanceof PmAttr<?>) {
     return ((PmAttr<?>) cell).getValueLocalized();
   }
   return cell.getPmTitle();
 }
コード例 #5
0
 /**
  * Gets the shared instance from the related {@link PmConversation}.
  *
  * <p>If instance was found for the requuested object name, an named object will be created using
  * the method {@link #create()}.
  *
  * @return the shared named object.
  */
 @SuppressWarnings("unchecked")
 public T getRef() {
   if (namedObj == null) {
     namedObj = (T) pmCtxt.getPmConversation().getPmNamedObject(name);
     if (namedObj == null) {
       namedObj = create();
       pmCtxt.getPmConversation().setPmNamedObject(name, namedObj);
     }
   }
   return namedObj;
 }
コード例 #6
0
 public DeprFilterByDefinitionBase(PmObject pmCtxt, Class<?>... compOpClasses) {
   this(pmCtxt.getPmName(), pmCtxt.getPmTitle());
   compOps = new ArrayList<DeprCompOp>(compOpClasses.length);
   for (Class<?> c : compOpClasses) {
     Constructor<?> constructor = ClassUtil.findConstructor(c, PmObject.class);
     if (constructor == null) {
       throw new PmRuntimeException(
           pmCtxt,
           "DeprCompOp class needs a constructor with a single PmObject parameter to be useable in this context: "
               + c);
     }
     DeprCompOp compOp = ClassUtil.newInstance(constructor, pmCtxt);
     compOps.add(compOp);
   }
 }
コード例 #7
0
ファイル: _PmAssert.java プロジェクト: ulehnerhs/org.pm4j
 /**
  * Validates the PM tree having the given root instance. Fails if the subtree has validated
  * successfully or doesn't contain exactly the expected messages.
  *
  * @param rootPm The root of the PM tree to validate.
  * @param minSeverity The minimum severity to consider.
  * @param expectedMessagesInSubtree The expected messages in rootPm or its PM subtree.
  */
 public static void validateNotSuccessful(
     PmObject rootPm, Severity minSeverity, String... expectedMessagesInSubtree) {
   if (PmValidationApi.validateSubTree(rootPm)) {
     Assert.fail("Unexpected successful validation of " + rootPm.getPmRelativeName());
   }
   assertMessageText(rootPm, minSeverity, expectedMessagesInSubtree);
 }
コード例 #8
0
ファイル: _PmAssert.java プロジェクト: ulehnerhs/org.pm4j
 /**
  * Validates the PM tree having the given root instance. Fails if the subtree has any messages
  * after the validation call.
  *
  * @param rootPm The root of the PM tree to validate.
  */
 public static void validateSuccessful(PmObject rootPm) {
   if (!PmValidationApi.validateSubTree(rootPm)) {
     List<String> msgStrings = new ArrayList<String>();
     for (PmMessage m : PmMessageApi.getPmTreeMessages(rootPm, Severity.INFO)) {
       msgStrings.add(m.toString());
     }
     Assert.fail(
         "Unexpected messages after validation of "
             + rootPm.getPmRelativeName()
             + ":\n"
             + StringUtils.join(msgStrings.toArray(), "\n\t"));
   }
 }
コード例 #9
0
 /**
  * Translates the given set of bean validation messages to {@link PmValidationMessage}s.
  *
  * @param pm The PM to report the messages for.
  * @param violations The set of bean constraint validations to translate.
  */
 static void beanConstraintViolationsToPmMessages(
     PmObject pm, Set<ConstraintViolation<?>> violations) {
   if (violations != null) {
     for (ConstraintViolation<?> v : violations) {
       // TODO olaf: add handling for translated strings.
       //             what is the result of:
       // System.out.println("v.getMessageTemplate: '" + v.getMessageTemplate() + "'  message: " +
       // v.getMessage());
       PmValidationMessage msg =
           new PmValidationMessage(pm, PmConstants.MSGKEY_FIRST_MSG_PARAM, v.getMessage(), v);
       pm.getPmConversation().addPmMessage(msg);
     }
   }
 }
コード例 #10
0
ファイル: PmTabSetImpl.java プロジェクト: mpetersen/org.pm4j
 public boolean isDecoratorForSwitch(PmObject fromTab, PmObject toTab) {
   return ((toName == null) || (toTab != null && toTab.getPmRelativeName().equals(toName)))
       && ((fromName == null)
           || (fromTab != null) && fromTab.getPmRelativeName().equals(fromName));
 }
コード例 #11
0
ファイル: PmTabSetImpl.java プロジェクト: mpetersen/org.pm4j
 public CmdDecoratorDefintion(PmObject fromTab, PmObject toTab, PmCommandDecorator decorator) {
   this(
       fromTab != null ? fromTab.getPmRelativeName() : null,
       toTab != null ? toTab.getPmRelativeName() : null,
       decorator);
 }
コード例 #12
0
ファイル: _PmAssert.java プロジェクト: ulehnerhs/org.pm4j
 /**
  * Checks that there are no active {@link PmMessage}s within the {@link
  * org.pm4j.core.pm.PmConversation} of the given PM.
  *
  * @param msg the assert message to display if the check fails.
  * @param pm the PM to perform the check for.
  */
 public static void assertNoMessagesInConversation(String msg, PmObject pm) {
   assertNoMessagesInSubTree(msg, pm.getPmConversation());
 }
コード例 #13
0
ファイル: _PmAssert.java プロジェクト: ulehnerhs/org.pm4j
 /**
  * Checks that there are no active {@link PmMessage}s within the {@link
  * org.pm4j.core.pm.PmConversation} of the given PM.
  *
  * @param pm the PM to perform the check for.
  */
 public static void assertNoMessagesInConversation(PmObject pm) {
   assertNoMessagesInSubTree(pm.getPmConversation());
 }
コード例 #14
0
ファイル: _PmAssert.java プロジェクト: ulehnerhs/org.pm4j
 /**
  * Checks that there are no active {@link PmMessage}s with the given <code>minSeverity</code> for
  * the given PM (incl. its sub-PMs)
  *
  * @param msg the assert message to display if the check fails.
  * @param pm the PM to perform the check for.
  * @param minSeverity the minimum severity to consider.
  */
 public static void assertNoMessagesInSubTree(String msg, PmObject pm, Severity minSeverity) {
   String errMsgs = subTreeMessagesToString(pm, minSeverity);
   if (StringUtils.isNotBlank(errMsgs)) {
     Assert.fail(msg + " " + pm.getPmRelativeName() + ": " + errMsgs);
   }
 }