From 6a9b10c71570432193998a4b1bc4cde150827516 Mon Sep 17 00:00:00 2001
From: "elena.parovyshnaya"
Date: Thu, 9 Jul 2020 11:08:57 +0300
Subject: [PATCH 1/3] Bug 565011 rebuild the core of condition expression
evaluation
- Implement all `yet-to-be-done`-s in
`lic.internal.conditions.evaluation`
Signed-off-by: elena.parovyshnaya
---
.../api/conditions/evaluation/Emission.java | 17 +++--
...ava => ExpressionEvaluationException.java} | 20 +++---
.../ExpressionEvaluationService.java | 9 ++-
...ice.java => ExpressionParsingService.java} | 2 +-
.../evaluation/ExpressionPasringRegistry.java | 2 +-
.../ExpressionTokenAssessmentService.java | 19 +++--
.../api/diagnostic/FailureDiagnostic.java} | 11 +--
.../META-INF/MANIFEST.MF | 1 +
.../base/conditions/LicensingConditions.java | 6 +-
.../AndsProtocolExpressionParseService.java | 39 +++++++---
.../BasePermissionEmittingService.java | 49 ++++++++-----
.../evaluation/FormalizedExpression.java | 10 +--
.../SimpleMapExpressionEvaluationService.java | 44 ++++++++++--
.../conditions/evaluation/SumOfEmissions.java | 10 ++-
.../diagnostic/BaseFailureDiagnostic.java | 71 +++++++++++++++++++
.../i18n/ConditionsEvaluationMessages.java | 33 +++++++++
.../ConditionsEvaluationMessages.properties | 21 ++++++
.../demo/SealedAccessCycleConfiguration.java | 4 +-
.../FakeConditionExpressionEvaluator.java | 0
.../FakeConditionExpressionParser.java | 0
.../FakeExpressionTokenAssessmentService.java | 0
.../mining}/FakeMinedConditions.java | 0
.../{ => io}/FakeConditionTransport.java | 0
.../tests/fakes/{ => io}/FakeKeyKeeper.java | 0
.../tests/fakes/{ => io}/FakeStreamCodec.java | 0
.../fakes/{ => requirements}/FakeFeature.java | 0
.../{ => requirements}/FakeRequirement.java | 0
.../FakeResolvedRequirements.java | 0
28 files changed, 296 insertions(+), 72 deletions(-)
rename bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/{EmissionFailureDiagnostic.java => ExpressionEvaluationException.java} (57%)
rename bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/{ExpressionPasringService.java => ExpressionParsingService.java} (91%)
rename bundles/{org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/BaseEmissionFailureDiagnostic.java => org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/diagnostic/FailureDiagnostic.java} (62%)
create mode 100644 bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/diagnostic/BaseFailureDiagnostic.java
create mode 100644 bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.java
create mode 100644 bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.properties
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => conditions/evaluation}/FakeConditionExpressionEvaluator.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => conditions/evaluation}/FakeConditionExpressionParser.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => conditions/evaluation}/FakeExpressionTokenAssessmentService.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => conditions/mining}/FakeMinedConditions.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => io}/FakeConditionTransport.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => io}/FakeKeyKeeper.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => io}/FakeStreamCodec.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => requirements}/FakeFeature.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => requirements}/FakeRequirement.java (100%)
rename tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/{ => requirements}/FakeResolvedRequirements.java (100%)
diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/Emission.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/Emission.java
index a80bacd19..31830375c 100644
--- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/Emission.java
+++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/Emission.java
@@ -13,8 +13,11 @@
package org.eclipse.passage.lic.internal.api.conditions.evaluation;
import java.util.Collection;
+import java.util.Collections;
import java.util.Objects;
+import org.eclipse.passage.lic.internal.api.diagnostic.FailureDiagnostic;
+
/**
* Report {@linkplain Condition}s evaluation results.
*
@@ -45,7 +48,7 @@ public interface Emission {
Collection permissions();
- EmissionFailureDiagnostic failureDiagnostic();
+ FailureDiagnostic failureDiagnostic();
public static final class Successful implements Emission {
@@ -56,6 +59,10 @@ public Successful(Collection permissions) {
this.permissions = permissions;
}
+ public Successful(Permission permission) {
+ this(Collections.singleton(permission));
+ }
+
@Override
public boolean failed() {
return false;
@@ -67,7 +74,7 @@ public Collection permissions() {
}
@Override
- public EmissionFailureDiagnostic failureDiagnostic() {
+ public FailureDiagnostic failureDiagnostic() {
throw new UnsupportedOperationException();
}
@@ -75,9 +82,9 @@ public EmissionFailureDiagnostic failureDiagnostic() {
public static final class Failed implements Emission {
- private final EmissionFailureDiagnostic diagnose;
+ private final FailureDiagnostic diagnose;
- public Failed(EmissionFailureDiagnostic diagnose) {
+ public Failed(FailureDiagnostic diagnose) {
Objects.requireNonNull(diagnose, "Emission.Failed::diagnose"); //$NON-NLS-1$
this.diagnose = diagnose;
}
@@ -93,7 +100,7 @@ public Collection permissions() {
}
@Override
- public EmissionFailureDiagnostic failureDiagnostic() {
+ public FailureDiagnostic failureDiagnostic() {
return diagnose;
}
diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/EmissionFailureDiagnostic.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionEvaluationException.java
similarity index 57%
rename from bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/EmissionFailureDiagnostic.java
rename to bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionEvaluationException.java
index e75f45944..f960acabc 100644
--- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/EmissionFailureDiagnostic.java
+++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionEvaluationException.java
@@ -12,15 +12,15 @@
*******************************************************************************/
package org.eclipse.passage.lic.internal.api.conditions.evaluation;
-/**
- *
- * FIXME: diagnostic details structure are yet to be designed as existing
- * emission process is reimplemented on top of these interfaces. Do we need try
- * to evaluate the rest of the condition after the first failure to get the full
- * picture? Or this first failure is enough? The answer will affect further
- * development of this interface.
- *
- */
-public interface EmissionFailureDiagnostic {
+@SuppressWarnings("serial")
+public final class ExpressionEvaluationException extends Exception {
+
+ public ExpressionEvaluationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ExpressionEvaluationException(String message) {
+ super(message);
+ }
}
diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionEvaluationService.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionEvaluationService.java
index 935f1cfed..e906d168d 100644
--- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionEvaluationService.java
+++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionEvaluationService.java
@@ -16,6 +16,13 @@
public interface ExpressionEvaluationService extends Service {
- boolean evaluate(ParsedExpression expression, ExpressionTokenAssessmentService assessor);
+ /**
+ * Assess the {@code expression} tokens with the given {@code assessor}.
+ *
+ * @throws ExpressionEvaluationException in case of infrastructure denial or
+ * assessment failure
+ */
+ void evaluate(ParsedExpression expression, ExpressionTokenAssessmentService assessor)
+ throws ExpressionEvaluationException;
}
diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionPasringService.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionParsingService.java
similarity index 91%
rename from bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionPasringService.java
rename to bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionParsingService.java
index e3281388b..74c881ef7 100644
--- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionPasringService.java
+++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionParsingService.java
@@ -14,7 +14,7 @@
import org.eclipse.passage.lic.internal.api.registry.Service;
-public interface ExpressionPasringService extends Service {
+public interface ExpressionParsingService extends Service {
ParsedExpression parsed(String expression) throws ExpressionParsingException;
diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionPasringRegistry.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionPasringRegistry.java
index cba61958a..086c647c0 100644
--- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionPasringRegistry.java
+++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionPasringRegistry.java
@@ -16,6 +16,6 @@
import org.eclipse.passage.lic.internal.api.registry.Registry;
-public interface ExpressionPasringRegistry extends Supplier> {
+public interface ExpressionPasringRegistry extends Supplier> {
}
diff --git a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionTokenAssessmentService.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionTokenAssessmentService.java
index 6159fa8c7..99ab87e54 100644
--- a/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionTokenAssessmentService.java
+++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/conditions/evaluation/ExpressionTokenAssessmentService.java
@@ -31,15 +31,20 @@
* must answer only these simple questions. the rest of the evaluation logic is
* on {@linkplain ExpressionProtocol}-aware services.
*
+ *
+ * This interface is to be extended further to cover all atomic queries we might
+ * need.
+ *
*/
public interface ExpressionTokenAssessmentService extends Service {
- boolean equal(String key, String value);
-
- // contains ()
-
- // startsWith ()
-
- // all the things we will ever need -> slice to [Operation]s
+ /**
+ * Assess dedicated part of the runtime environment is the given property
+ * {@code key} equals to the expected {@code value}.
+ *
+ * @throws ExpressionEvaluationException in the case of any evaluation
+ * infrastructure denial or misbehavior
+ */
+ boolean equal(String key, String value) throws ExpressionEvaluationException;
}
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/BaseEmissionFailureDiagnostic.java b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/diagnostic/FailureDiagnostic.java
similarity index 62%
rename from bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/BaseEmissionFailureDiagnostic.java
rename to bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/diagnostic/FailureDiagnostic.java
index 099da6a7c..98ef8353a 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/BaseEmissionFailureDiagnostic.java
+++ b/bundles/org.eclipse.passage.lic.api/src/org/eclipse/passage/lic/internal/api/diagnostic/FailureDiagnostic.java
@@ -10,11 +10,12 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.internal.base.conditions.evaluation;
+package org.eclipse.passage.lic.internal.api.diagnostic;
-import org.eclipse.passage.lic.internal.api.conditions.evaluation.EmissionFailureDiagnostic;
+import java.util.List;
+
+public interface FailureDiagnostic {
+
+ List troubles();
-@SuppressWarnings("restriction")
-final class BaseEmissionFailureDiagnostic implements EmissionFailureDiagnostic {
- // FIXME: ytbd
}
diff --git a/bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF
index f4d9cf430..83505197d 100644
--- a/bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Export-Package: org.eclipse.passage.lic.base,
org.eclipse.passage.lic.internal.base.conditions;x-internal:=true,
org.eclipse.passage.lic.internal.base.conditions.evaluation;x-internal:=true,
org.eclipse.passage.lic.internal.base.conditions.mining;x-internal:=true,
+ org.eclipse.passage.lic.internal.base.diagnostic;x-internal:=true,
org.eclipse.passage.lic.internal.base.i18n;x-internal:=true,
org.eclipse.passage.lic.internal.base.io;x-internal:=true,
org.eclipse.passage.lic.internal.base.permission;x-internal:=true,
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/LicensingConditions.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/LicensingConditions.java
index 32248b589..12fc2a237 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/LicensingConditions.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/conditions/LicensingConditions.java
@@ -22,6 +22,7 @@
import org.eclipse.passage.lic.api.conditions.LicensingCondition;
import org.eclipse.passage.lic.base.BaseLicensingResult;
import org.eclipse.passage.lic.base.LicensingResults;
+import org.eclipse.passage.lic.internal.base.conditions.evaluation.AndsProtocolExpressionParseService;
import org.eclipse.passage.lic.internal.base.i18n.BaseMessages;
public class LicensingConditions {
@@ -33,10 +34,13 @@ private LicensingConditions() {
// block
}
+ /**
+ * @deprecated use {@link AndsProtocolExpressionParseService}
+ */
+ @Deprecated
public static Map parseExpression(String expression) {
Map map = new HashMap<>();
if (expression == null) {
- // FIXME: report error;
return map;
}
String[] segments = expression.split(SEGMENT_SEPARATOR);
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/AndsProtocolExpressionParseService.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/AndsProtocolExpressionParseService.java
index c84102b06..ce3019e0c 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/AndsProtocolExpressionParseService.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/AndsProtocolExpressionParseService.java
@@ -17,17 +17,20 @@
import java.util.Objects;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionParsingException;
-import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionPasringService;
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionParsingService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionProtocol;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ParsedExpression;
+import org.eclipse.passage.lic.internal.base.i18n.ConditionsEvaluationMessages;
/**
*
*/
@SuppressWarnings("restriction")
-public final class AndsProtocolExpressionParseService implements ExpressionPasringService {
+public final class AndsProtocolExpressionParseService implements ExpressionParsingService {
private final ExpressionProtocol protocol = new ExpressionProtocol.Ands();
+ private final String separator = ";"; //$NON-NLS-1$
+ private final String mediator = "="; //$NON-NLS-1$
@Override
public ExpressionProtocol id() {
@@ -37,17 +40,35 @@ public ExpressionProtocol id() {
/**
* Expect the incoming {@code expression} to be a semicolon-separated
* {@code key=value} pairs meaning {@code AND}-ed equality checks.
- *
- * FIXME: contract: situation must cause failure - cover it with a
- * contract test
- *
*/
@Override
public ParsedExpression parsed(String expression) throws ExpressionParsingException {
Objects.requireNonNull(expression);
- Map checks = new HashMap<>();
- // FIXME: ytbd: do further work: split and fill the map
- return new SimpleMapExpression(protocol, checks);
+ Map couples = new HashMap<>();
+ for (String segment : expression.split(separator)) {
+ addCouple(segment, couples);
+ }
+ if (couples.isEmpty()) {
+ throw new ExpressionParsingException(String.format(//
+ ConditionsEvaluationMessages.getString("AndsProtocolExpressionParseService.no_checks"), //$NON-NLS-1$
+ expression));
+ }
+ return new SimpleMapExpression(protocol, couples);
+ }
+
+ private void addCouple(String segment, Map couples) throws ExpressionParsingException {
+ String[] couple = segment.split(mediator);
+ if (coupleIsInvalid(couple)) {
+ throw new ExpressionParsingException(String.format(//
+ ConditionsEvaluationMessages.getString("AndsProtocolExpressionParseService.invalid_format"), segment)); //$NON-NLS-1$
+ }
+ couples.put(couple[0].trim(), couple[1].trim());
+ }
+
+ private boolean coupleIsInvalid(String[] couple) {
+ return (couple.length != 2) || //
+ couple[0].trim().isEmpty() || //
+ couple[1].trim().isEmpty();
}
}
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/BasePermissionEmittingService.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/BasePermissionEmittingService.java
index 676224e37..20d23e3aa 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/BasePermissionEmittingService.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/BasePermissionEmittingService.java
@@ -25,6 +25,7 @@
import org.eclipse.passage.lic.internal.api.conditions.ValidityPeriod;
import org.eclipse.passage.lic.internal.api.conditions.ValidityPeriodClosed;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.Emission;
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluationException;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluationService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluatorsRegistry;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionParsingException;
@@ -33,7 +34,12 @@
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionTokenAssessorsRegistry;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ParsedExpression;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.PermissionEmittingService;
+import org.eclipse.passage.lic.internal.api.diagnostic.code.LicenseCheckFailed;
+import org.eclipse.passage.lic.internal.api.diagnostic.code.LicenseDoesNotMatch;
+import org.eclipse.passage.lic.internal.api.diagnostic.code.LicenseInvalid;
import org.eclipse.passage.lic.internal.api.registry.StringServiceId;
+import org.eclipse.passage.lic.internal.base.diagnostic.BaseFailureDiagnostic;
+import org.eclipse.passage.lic.internal.base.i18n.ConditionsEvaluationMessages;
@SuppressWarnings("restriction")
public final class BasePermissionEmittingService implements PermissionEmittingService {
@@ -70,34 +76,45 @@ public Emission emit(Collection conditions, LicensedProduct product)
}
private Emission emitFor(Condition condition, LicensedProduct product) {
- boolean satisfied = false;
try {
- satisfied = expressionIsSatisfied(condition);
+ expressionIsSatisfied(condition);
} catch (ExpressionParsingException e) {
- new Emission.Failed(new BaseEmissionFailureDiagnostic()); // FIXME: ytbd: explain
+ return new Emission.Failed(new BaseFailureDiagnostic(//
+ new LicenseInvalid(), //
+ String.format(ConditionsEvaluationMessages.getString("BasePermissionEmittingService.parse_failed"), // //$NON-NLS-1$
+ condition.evaluationInstructions().expression()), //
+ e));
+ } catch (ExpressionEvaluationException e) {
+ return new Emission.Failed(new BaseFailureDiagnostic(//
+ new LicenseDoesNotMatch(), //
+ String.format(
+ ConditionsEvaluationMessages.getString("BasePermissionEmittingService.evaluation_failed"), // //$NON-NLS-1$
+ condition.evaluationInstructions().expression()), //
+ e));
} catch (LicensingException e) {
- new Emission.Failed(new BaseEmissionFailureDiagnostic()); // FIXME: ytbd: explain
- }
- if (satisfied) {
- return new Emission.Successful(Arrays.asList(//
- new BasePermission(//
- product, //
- condition, //
- ZonedDateTime.now(), //
- expiration(condition.validityPeriod()))));
- } else {
- return new Emission.Failed(new BaseEmissionFailureDiagnostic()); // FIXME: ytbd: explain
+ return new Emission.Failed(new BaseFailureDiagnostic(//
+ new LicenseCheckFailed(), //
+ String.format(ConditionsEvaluationMessages.getString("BasePermissionEmittingService.failed"), // //$NON-NLS-1$
+ condition.evaluationInstructions().expression()), //
+ e));
}
+ return new Emission.Successful(Arrays.asList(//
+ new BasePermission(//
+ product, //
+ condition, //
+ ZonedDateTime.now(), //
+ expiration(condition.validityPeriod()))));
}
- private boolean expressionIsSatisfied(Condition condition) throws LicensingException, ExpressionParsingException {
+ private void expressionIsSatisfied(Condition condition)
+ throws ExpressionParsingException, ExpressionEvaluationException, LicensingException {
ExpressionTokenAssessmentService assessor = //
evaluator(condition.evaluationInstructions().type());
ParsedExpression expression = new FormalizedExpression( //
condition.evaluationInstructions().expression(), //
parsers.get()).get();
ExpressionEvaluationService evaluator = evaluators.get().service(expression.protocol());
- return evaluator.evaluate(expression, assessor);
+ evaluator.evaluate(expression, assessor);
}
private ExpressionTokenAssessmentService evaluator(EvaluationType type) throws LicensingException {
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/FormalizedExpression.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/FormalizedExpression.java
index 35ea1818f..8a5e791b7 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/FormalizedExpression.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/FormalizedExpression.java
@@ -15,7 +15,7 @@
import java.util.Objects;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionParsingException;
-import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionPasringService;
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionParsingService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionProtocol;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ParsedExpression;
import org.eclipse.passage.lic.internal.api.registry.Registry;
@@ -37,9 +37,9 @@ final class FormalizedExpression {
private final String raw;
private final String separator;
- private final Registry parsers;
+ private final Registry parsers;
- FormalizedExpression(String raw, String separator, Registry parsers) {
+ FormalizedExpression(String raw, String separator, Registry parsers) {
Objects.requireNonNull(raw, "RetrievedExpression::raw"); //$NON-NLS-1$
Objects.requireNonNull(separator, "RetrievedExpression::separator"); //$NON-NLS-1$
Objects.requireNonNull(parsers, "RetrievedExpression::parsers"); //$NON-NLS-1$
@@ -48,7 +48,7 @@ final class FormalizedExpression {
this.parsers = parsers;
}
- FormalizedExpression(String raw, Registry parsers) {
+ FormalizedExpression(String raw, Registry parsers) {
this(raw, "!!", parsers); //$NON-NLS-1$
}
@@ -56,7 +56,7 @@ ParsedExpression get() throws ExpressionParsingException {
return service().parsed(content());
}
- private ExpressionPasringService service() {
+ private ExpressionParsingService service() {
ExpressionProtocol protocol = protocol();
return parsers.hasService(protocol) //
? parsers.service(protocol) //
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/SimpleMapExpressionEvaluationService.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/SimpleMapExpressionEvaluationService.java
index e94006561..d5e061276 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/SimpleMapExpressionEvaluationService.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/SimpleMapExpressionEvaluationService.java
@@ -12,10 +12,12 @@
*******************************************************************************/
package org.eclipse.passage.lic.internal.base.conditions.evaluation;
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluationException;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluationService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionProtocol;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionTokenAssessmentService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ParsedExpression;
+import org.eclipse.passage.lic.internal.base.i18n.ConditionsEvaluationMessages;
@SuppressWarnings("restriction")
public final class SimpleMapExpressionEvaluationService implements ExpressionEvaluationService {
@@ -28,12 +30,42 @@ public ExpressionProtocol id() {
}
@Override
- public boolean evaluate(ParsedExpression expression, ExpressionTokenAssessmentService evaluator) {
- // FIXME: ytbd: if not instanceof - swear to diagnose
- SimpleMapExpression simple = (SimpleMapExpression) expression;
- // FIXME: ytbd: need report which check is failed
- return simple.keys().stream() //
- .allMatch(key -> evaluator.equal(key, simple.expected(key)));
+ public void evaluate(ParsedExpression expression, ExpressionTokenAssessmentService assessor)
+ throws ExpressionEvaluationException {
+ SimpleMapExpression map = map(expression);
+ for (String key : map.keys()) {
+ boolean passed = equal(key, map.expected(key), assessor);
+ if (!passed) {
+ throw new ExpressionEvaluationException(String.format(ConditionsEvaluationMessages.getString(//
+ "SimpleMapExpressionEvaluationService.segment_fails_evaluation"), //$NON-NLS-1$
+ assessor.id().identifier(), key, map.expected(key)));
+ }
+ }
+ }
+
+ private boolean equal(String key, String value, ExpressionTokenAssessmentService assessor)
+ throws ExpressionEvaluationException {
+ try {
+ return assessor.equal(key, value);
+ } catch (ExpressionEvaluationException e) {
+ throw new ExpressionEvaluationException(String.format(ConditionsEvaluationMessages.getString(//
+ "SimpleMapExpressionEvaluationService.evaluation_fails"), //$NON-NLS-1$
+ key, value, assessor.id().identifier()), e);
+ }
+ }
+
+ private SimpleMapExpression map(ParsedExpression expression) throws ExpressionEvaluationException {
+ if (!SimpleMapExpression.class.isInstance(expression)) {
+ new ExpressionEvaluationException(String.format(ConditionsEvaluationMessages.getString(//
+ "SimpleMapExpressionEvaluationService.foreign_expression"), // //$NON-NLS-1$
+ expression.protocol()));
+ }
+ SimpleMapExpression map = (SimpleMapExpression) expression;
+ if (map.keys().isEmpty()) {
+ new ExpressionEvaluationException(ConditionsEvaluationMessages.getString(//
+ "SimpleMapExpressionEvaluationService.no_checks")); //$NON-NLS-1$
+ }
+ return map;
}
}
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/SumOfEmissions.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/SumOfEmissions.java
index e324572b5..934a97169 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/SumOfEmissions.java
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/conditions/evaluation/SumOfEmissions.java
@@ -14,12 +14,14 @@
import java.util.Arrays;
import java.util.Collection;
+import java.util.Objects;
import java.util.function.BinaryOperator;
import java.util.stream.Collectors;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.Emission;
-import org.eclipse.passage.lic.internal.api.conditions.evaluation.EmissionFailureDiagnostic;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.Permission;
+import org.eclipse.passage.lic.internal.api.diagnostic.FailureDiagnostic;
+import org.eclipse.passage.lic.internal.base.diagnostic.BaseFailureDiagnostic;
@SuppressWarnings("restriction")
public final class SumOfEmissions implements BinaryOperator {
@@ -31,11 +33,13 @@ public Emission apply(Emission first, Emission second) {
: new Emission.Successful(sumPermissions(first, second));
}
- private EmissionFailureDiagnostic sumDiagnostic(Emission first, Emission second) {
- return new BaseEmissionFailureDiagnostic(); // FIXME: implement
+ private FailureDiagnostic sumDiagnostic(Emission first, Emission second) {
+ return new BaseFailureDiagnostic(first, second);
}
private Collection sumPermissions(Emission first, Emission second) {
+ Objects.requireNonNull(first);
+ Objects.requireNonNull(second);
return Arrays.asList(first.permissions(), second.permissions()).stream()//
.flatMap(Collection::stream) //
.collect(Collectors.toList());
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/diagnostic/BaseFailureDiagnostic.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/diagnostic/BaseFailureDiagnostic.java
new file mode 100644
index 000000000..9d8592288
--- /dev/null
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/diagnostic/BaseFailureDiagnostic.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * https://www.eclipse.org/legal/epl-2.0/.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * ArSysOp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.passage.lic.internal.base.diagnostic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.Emission;
+import org.eclipse.passage.lic.internal.api.diagnostic.FailureDiagnostic;
+import org.eclipse.passage.lic.internal.api.diagnostic.Trouble;
+import org.eclipse.passage.lic.internal.api.diagnostic.TroubleCode;
+
+@SuppressWarnings("restriction")
+public final class BaseFailureDiagnostic implements FailureDiagnostic {
+
+ private final List troubles;
+
+ public BaseFailureDiagnostic(List troubles) {
+ Objects.requireNonNull(troubles);
+ if (troubles.isEmpty()) {
+ throw new IllegalArgumentException("Diagnostic is not useful without any information"); //$NON-NLS-1$
+ }
+ this.troubles = new ArrayList<>(troubles);
+ }
+
+ public BaseFailureDiagnostic(Trouble trouble) {
+ this(Collections.singletonList(trouble));
+ }
+
+ public BaseFailureDiagnostic(TroubleCode code, String details, Exception exception) {
+ this(Collections.singletonList(new Trouble(code, details, exception)));
+ }
+
+ public BaseFailureDiagnostic(TroubleCode code, String details) {
+ this(Collections.singletonList(new Trouble(code, details)));
+ }
+
+ public BaseFailureDiagnostic(Emission first, Emission second) {
+ if (!first.failed() && !second.failed()) {
+ throw new IllegalArgumentException("Diagnostic supposes failure"); //$NON-NLS-1$
+ }
+ troubles = new ArrayList();
+ append(first);
+ append(second);
+
+ }
+
+ private void append(Emission emission) {
+ if (!emission.failed()) {
+ return;
+ }
+ troubles.addAll(emission.failureDiagnostic().troubles());
+ }
+
+ @Override
+ public List troubles() {
+ return troubles;
+ }
+}
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.java
new file mode 100644
index 000000000..a050edd91
--- /dev/null
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * https://www.eclipse.org/legal/epl-2.0/.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * ArSysOp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.passage.lic.internal.base.i18n;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class ConditionsEvaluationMessages {
+ private static final String BUNDLE_NAME = "org.eclipse.passage.lic.internal.base.i18n.ConditionsEvaluationMessages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private ConditionsEvaluationMessages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.properties b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.properties
new file mode 100644
index 000000000..b0ba26822
--- /dev/null
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.properties
@@ -0,0 +1,21 @@
+AndsProtocolExpressionParseService.invalid_format=Segment [%s] is corrupled. Expected to have key=value structure.
+AndsProtocolExpressionParseService.no_checks=Expression [%s] contains no checks. Expected to be of [key=value;...key=value] structure.
+BasePermissionEmittingService.failed=Failed to assess expression [%s]
+BasePermissionEmittingService.parse_failed=Failed to parse expression [%s]
+###############################################################################
+# Copyright (c) 2020 ArSysOp and others
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License 2.0 which is available at
+# https://www.eclipse.org/legal/epl-2.0/.
+#
+# SPDX-License-Identifier: EPL-2.0
+#
+# Contributors:
+# ArSysOp - initial API and implementation
+###############################################################################
+BasePermissionEmittingService.evaluation_failed=Failed to evaluate expression [%s]
+SimpleMapExpressionEvaluationService.foreign_expression=Expression protocol [%s] does not fit the expected [ands]
+SimpleMapExpressionEvaluationService.no_checks=Expression is invalid: it contains no checks
+SimpleMapExpressionEvaluationService.segment_fails_evaluation=Expression fails evaluation (type %s) on segment [%s = %s]
+SimpleMapExpressionEvaluationService.evaluation_fails=Expression segment [%s = %s] %s assessment failed with error
diff --git a/bundles/org.eclipse.passage.seal.demo/src/org/eclipse/passage/seal/internal/demo/SealedAccessCycleConfiguration.java b/bundles/org.eclipse.passage.seal.demo/src/org/eclipse/passage/seal/internal/demo/SealedAccessCycleConfiguration.java
index 7ee284be1..a24495e89 100644
--- a/bundles/org.eclipse.passage.seal.demo/src/org/eclipse/passage/seal/internal/demo/SealedAccessCycleConfiguration.java
+++ b/bundles/org.eclipse.passage.seal.demo/src/org/eclipse/passage/seal/internal/demo/SealedAccessCycleConfiguration.java
@@ -26,7 +26,7 @@
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluatorsRegistry;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionProtocol;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionPasringRegistry;
-import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionPasringService;
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionParsingService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionTokenAssessmentService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionTokenAssessorsRegistry;
import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionTransport;
@@ -70,7 +70,7 @@ final class SealedAccessCycleConfiguration implements AccessCycleConfiguration {
private final Registry codecs;
private final Registry keys;
private final Registry emitters;
- private final Registry expressionParsers;
+ private final Registry expressionParsers;
private final Registry expressionEvaluators;
private final Registry tokenEvaluators;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeConditionExpressionEvaluator.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionEvaluator.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeConditionExpressionEvaluator.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionEvaluator.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeConditionExpressionParser.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionParser.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeConditionExpressionParser.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionParser.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeExpressionTokenAssessmentService.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeExpressionTokenAssessmentService.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeExpressionTokenAssessmentService.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeExpressionTokenAssessmentService.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeMinedConditions.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/mining/FakeMinedConditions.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeMinedConditions.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/mining/FakeMinedConditions.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeConditionTransport.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeConditionTransport.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeConditionTransport.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeConditionTransport.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeKeyKeeper.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeKeyKeeper.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeKeyKeeper.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeKeyKeeper.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeStreamCodec.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeStreamCodec.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeStreamCodec.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeStreamCodec.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeFeature.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeFeature.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeRequirement.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeRequirement.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeRequirement.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeRequirement.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeResolvedRequirements.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeResolvedRequirements.java
similarity index 100%
rename from tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeResolvedRequirements.java
rename to tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeResolvedRequirements.java
From 6a861b30cd60cf16140d94b7ba51491096d6c950 Mon Sep 17 00:00:00 2001
From: "elena.parovyshnaya"
Date: Thu, 9 Jul 2020 11:15:41 +0300
Subject: [PATCH 2/3] Bug 565011 rebuild the core of condition expression
evaluation
- evolve `api.fakes`
- start testing `lic.internal.conditions.evaluation`.
Signed-off-by: elena.parovyshnaya
---
.../META-INF/MANIFEST.MF | 7 +++
.../lic/api/tests/FrameworkContractTest.java | 16 +++---
...eworkRequirementResolutionServiceTest.java | 2 +-
.../ResolvedRequirementsContractTest.java | 2 +-
.../tests/fakes/conditions/FakeCondition.java | 43 ++++++++++++++
.../FakeConditionExpressionEvaluator.java | 7 ++-
.../FakeConditionExpressionParser.java | 6 +-
.../FakeExpressionTokenAssessmentService.java | 2 +-
.../conditions/evaluation/FakePermission.java | 44 ++++++++++++++
.../mining/FakeMinedConditions.java | 2 +-
.../diagnostic/FakeFailureDiagnostic.java | 28 +++++++++
.../fakes/io/FakeConditionTransport.java | 2 +-
.../lic/api/tests/fakes/io/FakeKeyKeeper.java | 2 +-
.../api/tests/fakes/io/FakeStreamCodec.java | 2 +-
.../tests/fakes/requirements/FakeFeature.java | 2 +-
.../fakes/requirements/FakeRequirement.java | 2 +-
.../FakeResolvedRequirements.java | 2 +-
.../META-INF/MANIFEST.MF | 3 +-
.../tobemoved/XmiConditionTransportTest.java | 57 +++++++++++++++++++
19 files changed, 207 insertions(+), 24 deletions(-)
create mode 100644 tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/FakeCondition.java
create mode 100644 tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakePermission.java
create mode 100644 tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/diagnostic/FakeFailureDiagnostic.java
create mode 100644 tests/org.eclipse.passage.lic.licenses.migration.tests/src/org/eclipse/passage/lic/licenses/migration/tests/tobemoved/XmiConditionTransportTest.java
diff --git a/tests/org.eclipse.passage.lic.api.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.passage.lic.api.tests/META-INF/MANIFEST.MF
index 2aece1536..14de1ee60 100644
--- a/tests/org.eclipse.passage.lic.api.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.passage.lic.api.tests/META-INF/MANIFEST.MF
@@ -11,6 +11,13 @@ Require-Bundle: org.junit;bundle-version="4.12.0",
org.eclipse.passage.lic.api;bundle-version="0.7.0"
Export-Package: org.eclipse.passage.lic.api.tests;x-internal:=true,
org.eclipse.passage.lic.api.tests.conditions;x-internal:=true,
+ org.eclipse.passage.lic.api.tests.conditions.evaluation;x-internal:=true,
org.eclipse.passage.lic.api.tests.conditions.mining;x-internal:=true,
+ org.eclipse.passage.lic.api.tests.fakes.conditions;x-internal:=true,
+ org.eclipse.passage.lic.api.tests.fakes.conditions.evaluation,
+ org.eclipse.passage.lic.api.tests.fakes.conditions.mining;x-internal:=true,
+ org.eclipse.passage.lic.api.tests.fakes.diagnostic;x-internal:=true,
+ org.eclipse.passage.lic.api.tests.fakes.io;x-internal:=true,
+ org.eclipse.passage.lic.api.tests.fakes.requirements;x-internal:=true,
org.eclipse.passage.lic.api.tests.registry;x-internal:=true,
org.eclipse.passage.lic.api.tests.version;x-internal:=true
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/FrameworkContractTest.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/FrameworkContractTest.java
index d979ef2d2..b74e6ef4f 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/FrameworkContractTest.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/FrameworkContractTest.java
@@ -17,14 +17,14 @@
import java.util.Optional;
-import org.eclipse.passage.lic.api.tests.fakes.FakeConditionExpressionEvaluator;
-import org.eclipse.passage.lic.api.tests.fakes.FakeConditionExpressionParser;
-import org.eclipse.passage.lic.api.tests.fakes.FakeConditionTransport;
-import org.eclipse.passage.lic.api.tests.fakes.FakeExpressionTokenAssessmentService;
-import org.eclipse.passage.lic.api.tests.fakes.FakeKeyKeeper;
-import org.eclipse.passage.lic.api.tests.fakes.FakeMinedConditions;
-import org.eclipse.passage.lic.api.tests.fakes.FakeResolvedRequirements;
-import org.eclipse.passage.lic.api.tests.fakes.FakeStreamCodec;
+import org.eclipse.passage.lic.api.tests.fakes.conditions.evaluation.FakeConditionExpressionEvaluator;
+import org.eclipse.passage.lic.api.tests.fakes.conditions.evaluation.FakeConditionExpressionParser;
+import org.eclipse.passage.lic.api.tests.fakes.conditions.evaluation.FakeExpressionTokenAssessmentService;
+import org.eclipse.passage.lic.api.tests.fakes.conditions.mining.FakeMinedConditions;
+import org.eclipse.passage.lic.api.tests.fakes.io.FakeConditionTransport;
+import org.eclipse.passage.lic.api.tests.fakes.io.FakeKeyKeeper;
+import org.eclipse.passage.lic.api.tests.fakes.io.FakeStreamCodec;
+import org.eclipse.passage.lic.api.tests.fakes.requirements.FakeResolvedRequirements;
import org.eclipse.passage.lic.internal.api.AccessCycleConfiguration;
import org.eclipse.passage.lic.internal.api.Framework;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionProtocol;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/FrameworkRequirementResolutionServiceTest.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/FrameworkRequirementResolutionServiceTest.java
index 82abb01b2..3723a498d 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/FrameworkRequirementResolutionServiceTest.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/FrameworkRequirementResolutionServiceTest.java
@@ -16,7 +16,7 @@
import java.util.Optional;
import java.util.function.Supplier;
-import org.eclipse.passage.lic.api.tests.fakes.FakeResolvedRequirements;
+import org.eclipse.passage.lic.api.tests.fakes.requirements.FakeResolvedRequirements;
import org.eclipse.passage.lic.internal.api.Framework;
import org.eclipse.passage.lic.internal.api.requirements.ResolvedRequirements;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/ResolvedRequirementsContractTest.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/ResolvedRequirementsContractTest.java
index 3ea85129f..e2ce87c2d 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/ResolvedRequirementsContractTest.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/ResolvedRequirementsContractTest.java
@@ -15,7 +15,7 @@
import java.util.Collection;
import java.util.function.Supplier;
-import org.eclipse.passage.lic.api.tests.fakes.FakeRequirement;
+import org.eclipse.passage.lic.api.tests.fakes.requirements.FakeRequirement;
import org.eclipse.passage.lic.internal.api.requirements.Requirement;
import org.eclipse.passage.lic.internal.api.requirements.ResolvedRequirements;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/FakeCondition.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/FakeCondition.java
new file mode 100644
index 000000000..55c39d97b
--- /dev/null
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/FakeCondition.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * https://www.eclipse.org/legal/epl-2.0/.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * ArSysOp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.passage.lic.api.tests.fakes.conditions;
+
+import org.eclipse.passage.lic.internal.api.conditions.Condition;
+import org.eclipse.passage.lic.internal.api.conditions.EvaluationInstructions;
+import org.eclipse.passage.lic.internal.api.conditions.ValidityPeriod;
+import org.eclipse.passage.lic.internal.api.conditions.VersionMatch;
+
+@SuppressWarnings("restriction")
+public final class FakeCondition implements Condition {
+
+ @Override
+ public VersionMatch versionMatch() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ValidityPeriod validityPeriod() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public String feature() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public EvaluationInstructions evaluationInstructions() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionEvaluator.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionEvaluator.java
index c98b21459..6b9792575 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionEvaluator.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionEvaluator.java
@@ -10,8 +10,9 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.conditions.evaluation;
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluationException;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionEvaluationService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionProtocol;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionTokenAssessmentService;
@@ -26,8 +27,10 @@ public ExpressionProtocol id() {
}
@Override
- public boolean evaluate(ParsedExpression expression, ExpressionTokenAssessmentService tokenEvaluator) {
+ public void evaluate(ParsedExpression expression, ExpressionTokenAssessmentService assessor)
+ throws ExpressionEvaluationException {
throw new UnsupportedOperationException();
+
}
}
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionParser.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionParser.java
index 2131eb3d9..d1d9916d0 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionParser.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeConditionExpressionParser.java
@@ -10,15 +10,15 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.conditions.evaluation;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionProtocol;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionParsingException;
-import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionPasringService;
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionParsingService;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ParsedExpression;
@SuppressWarnings("restriction")
-public final class FakeConditionExpressionParser implements ExpressionPasringService {
+public final class FakeConditionExpressionParser implements ExpressionParsingService {
@Override
public ExpressionProtocol id() {
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeExpressionTokenAssessmentService.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeExpressionTokenAssessmentService.java
index e5b4becc8..09ba17b53 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeExpressionTokenAssessmentService.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakeExpressionTokenAssessmentService.java
@@ -10,7 +10,7 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.conditions.evaluation;
import org.eclipse.passage.lic.internal.api.conditions.EvaluationType;
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionTokenAssessmentService;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakePermission.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakePermission.java
new file mode 100644
index 000000000..898b63ac1
--- /dev/null
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/evaluation/FakePermission.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * https://www.eclipse.org/legal/epl-2.0/.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * ArSysOp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.passage.lic.api.tests.fakes.conditions.evaluation;
+
+import java.time.ZonedDateTime;
+
+import org.eclipse.passage.lic.internal.api.LicensedProduct;
+import org.eclipse.passage.lic.internal.api.conditions.Condition;
+import org.eclipse.passage.lic.internal.api.conditions.evaluation.Permission;
+
+@SuppressWarnings("restriction")
+public final class FakePermission implements Permission {
+
+ @Override
+ public LicensedProduct product() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Condition condition() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ZonedDateTime leaseDate() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ZonedDateTime expireDate() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/mining/FakeMinedConditions.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/mining/FakeMinedConditions.java
index b8244ddaf..f6bc11fc6 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/mining/FakeMinedConditions.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/conditions/mining/FakeMinedConditions.java
@@ -10,7 +10,7 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.conditions.mining;
import java.util.Collection;
import java.util.Collections;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/diagnostic/FakeFailureDiagnostic.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/diagnostic/FakeFailureDiagnostic.java
new file mode 100644
index 000000000..80966f28a
--- /dev/null
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/diagnostic/FakeFailureDiagnostic.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * https://www.eclipse.org/legal/epl-2.0/.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * ArSysOp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.passage.lic.api.tests.fakes.diagnostic;
+
+import java.util.List;
+
+import org.eclipse.passage.lic.internal.api.diagnostic.FailureDiagnostic;
+import org.eclipse.passage.lic.internal.api.diagnostic.Trouble;
+
+@SuppressWarnings("restriction")
+public final class FakeFailureDiagnostic implements FailureDiagnostic {
+
+ @Override
+ public List troubles() {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeConditionTransport.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeConditionTransport.java
index c9f879be1..50a038bb6 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeConditionTransport.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeConditionTransport.java
@@ -10,7 +10,7 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.io;
import java.io.IOException;
import java.io.InputStream;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeKeyKeeper.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeKeyKeeper.java
index 772a57a57..9044b168c 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeKeyKeeper.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeKeyKeeper.java
@@ -10,7 +10,7 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.io;
import java.io.InputStream;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeStreamCodec.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeStreamCodec.java
index 38ec2a079..9fdd46f6e 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeStreamCodec.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/io/FakeStreamCodec.java
@@ -10,7 +10,7 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.io;
import java.io.InputStream;
import java.io.OutputStream;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java
index 47885f529..18e051bac 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeFeature.java
@@ -10,7 +10,7 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.requirements;
import org.eclipse.passage.lic.internal.api.requirements.Feature;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeRequirement.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeRequirement.java
index e70e48cb3..73e42610e 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeRequirement.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeRequirement.java
@@ -10,7 +10,7 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.requirements;
import org.eclipse.passage.lic.internal.api.requirements.Feature;
import org.eclipse.passage.lic.internal.api.requirements.Requirement;
diff --git a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeResolvedRequirements.java b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeResolvedRequirements.java
index e3b3e14a3..0276579f5 100644
--- a/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeResolvedRequirements.java
+++ b/tests/org.eclipse.passage.lic.api.tests/src/org/eclipse/passage/lic/api/tests/fakes/requirements/FakeResolvedRequirements.java
@@ -10,7 +10,7 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
-package org.eclipse.passage.lic.api.tests.fakes;
+package org.eclipse.passage.lic.api.tests.fakes.requirements;
import java.util.Collection;
diff --git a/tests/org.eclipse.passage.lic.licenses.migration.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.passage.lic.licenses.migration.tests/META-INF/MANIFEST.MF
index 27aa2f997..244f8a7a8 100644
--- a/tests/org.eclipse.passage.lic.licenses.migration.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.passage.lic.licenses.migration.tests/META-INF/MANIFEST.MF
@@ -11,5 +11,6 @@ Require-Bundle: org.junit;bundle-version="4.12.0",
org.eclipse.emf.ecore.xmi;bundle-version="0.0.0",
org.eclipse.passage.lic.base;bundle-version="0.0.0",
org.eclipse.passage.lic.licenses.model;bundle-version="0.0.0",
- org.eclipse.passage.lic.licenses.migration;bundle-version="0.0.0"
+ org.eclipse.passage.lic.licenses.migration;bundle-version="0.0.0",
+ org.eclipse.passage.lic.api.tests;bundle-version="0.1.0"
Export-Package: org.eclipse.passage.lic.licenses.migration.tests;x-internal:=true
diff --git a/tests/org.eclipse.passage.lic.licenses.migration.tests/src/org/eclipse/passage/lic/licenses/migration/tests/tobemoved/XmiConditionTransportTest.java b/tests/org.eclipse.passage.lic.licenses.migration.tests/src/org/eclipse/passage/lic/licenses/migration/tests/tobemoved/XmiConditionTransportTest.java
new file mode 100644
index 000000000..f365b2a75
--- /dev/null
+++ b/tests/org.eclipse.passage.lic.licenses.migration.tests/src/org/eclipse/passage/lic/licenses/migration/tests/tobemoved/XmiConditionTransportTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2020 ArSysOp
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which is available at
+ * https://www.eclipse.org/legal/epl-2.0/.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * ArSysOp - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.passage.lic.licenses.migration.tests.tobemoved;
+
+import java.time.ZonedDateTime;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.passage.lic.api.tests.conditions.mining.ConditionTransportContractTest;
+import org.eclipse.passage.lic.internal.api.conditions.Condition;
+import org.eclipse.passage.lic.internal.api.conditions.EvaluationType;
+import org.eclipse.passage.lic.internal.api.conditions.mining.ConditionTransport;
+import org.eclipse.passage.lic.internal.base.conditions.BaseCondition;
+import org.eclipse.passage.lic.internal.base.conditions.BaseEvaluationInstructions;
+import org.eclipse.passage.lic.internal.base.conditions.BaseValidityPeriodClosed;
+import org.eclipse.passage.lic.internal.base.conditions.BaseVersionMatch;
+import org.eclipse.passage.lic.internal.base.conditions.MatchingRuleDefault;
+import org.eclipse.passage.lic.internal.licenses.migration.tobemoved.XmiConditionTransport;
+
+@SuppressWarnings("restriction")
+public class XmiConditionTransportTest extends ConditionTransportContractTest {
+ @Override
+ protected ConditionTransport transport() {
+ return new XmiConditionTransport();
+ }
+
+ @Override
+ protected Collection conditions() {
+ return Collections.singleton(new BaseCondition(//
+ "doodle", //$NON-NLS-1$
+ new BaseVersionMatch(//
+ "1.2.3", //$NON-NLS-1$
+ new MatchingRuleDefault()), //
+ new BaseValidityPeriodClosed(//
+ ZonedDateTime.now(), //
+ ZonedDateTime.now().plusYears(1)), //
+ new BaseEvaluationInstructions(//
+ new EvaluationType.Hardware(), //
+ "key=value"))); //$NON-NLS-1$
+ }
+
+ @Override
+ protected String serialized(Collection condition) {
+ return "TODO: get an xmi-persistence license text"; //$NON-NLS-1$
+ }
+
+}
From 7bb9af0bbb5da2bda03dd8111a26c615c342c82d Mon Sep 17 00:00:00 2001
From: "elena.parovyshnaya"
Date: Thu, 9 Jul 2020 12:54:08 +0300
Subject: [PATCH 3/3] Bug 565011 rebuild the core of condition expression
evaluation
- reorder `.properties` file and fix a typo
Signed-off-by: elena.parovyshnaya
---
.../base/i18n/ConditionsEvaluationMessages.properties | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.properties b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.properties
index b0ba26822..dc1e835c0 100644
--- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.properties
+++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/internal/base/i18n/ConditionsEvaluationMessages.properties
@@ -1,7 +1,3 @@
-AndsProtocolExpressionParseService.invalid_format=Segment [%s] is corrupled. Expected to have key=value structure.
-AndsProtocolExpressionParseService.no_checks=Expression [%s] contains no checks. Expected to be of [key=value;...key=value] structure.
-BasePermissionEmittingService.failed=Failed to assess expression [%s]
-BasePermissionEmittingService.parse_failed=Failed to parse expression [%s]
###############################################################################
# Copyright (c) 2020 ArSysOp and others
#
@@ -19,3 +15,7 @@ SimpleMapExpressionEvaluationService.foreign_expression=Expression protocol [%s]
SimpleMapExpressionEvaluationService.no_checks=Expression is invalid: it contains no checks
SimpleMapExpressionEvaluationService.segment_fails_evaluation=Expression fails evaluation (type %s) on segment [%s = %s]
SimpleMapExpressionEvaluationService.evaluation_fails=Expression segment [%s = %s] %s assessment failed with error
+AndsProtocolExpressionParseService.invalid_format=Segment [%s] is corrupted. Expected to have key=value structure.
+AndsProtocolExpressionParseService.no_checks=Expression [%s] contains no checks. Expected to be of [key=value;...key=value] structure.
+BasePermissionEmittingService.failed=Failed to assess expression [%s]
+BasePermissionEmittingService.parse_failed=Failed to parse expression [%s]