-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from eclipse-passage/565011
Bug 565011 rebuild the core of condition expression evaluation
- Loading branch information
Showing
11 changed files
with
412 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ssage.lic.api/src/org/eclipse/passage/lic/internal/api/registry/AggregativeServiceId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* 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.api.registry; | ||
|
||
import java.util.Objects; | ||
|
||
public final class AggregativeServiceId<I1 extends ServiceId, I2 extends ServiceId> implements ServiceId { | ||
|
||
private final I1 first; | ||
private final I2 second; | ||
|
||
public AggregativeServiceId(I1 first, I2 second) { | ||
this.first = first; | ||
this.second = second; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object object) { | ||
if (!AggregativeServiceId.class.isInstance(object)) { | ||
return false; | ||
} | ||
@SuppressWarnings("rawtypes") | ||
AggregativeServiceId another = (AggregativeServiceId) object; | ||
return first.equals(another.first) && second.equals(another.second); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(first, second); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s/%s", first, second); //$NON-NLS-1$ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...sts/src/org/eclipse/passage/lic/api/tests/conditions/evaluation/EmissionContractTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.api.tests.conditions.evaluation; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assume.assumeFalse; | ||
import static org.junit.Assume.assumeTrue; | ||
|
||
import org.eclipse.passage.lic.internal.api.conditions.evaluation.Emission; | ||
import org.junit.Test; | ||
|
||
@SuppressWarnings("restriction") | ||
public abstract class EmissionContractTest { | ||
|
||
@Test(expected = Exception.class) | ||
public void failedEmissionCannotHoldPermission() { | ||
Emission failure = failed(); | ||
assumeTrue(failure.failed()); | ||
failure.permissions(); | ||
} | ||
|
||
@Test | ||
public void successfulEmissionMustHoldPermission() { | ||
Emission success = successful(); | ||
assumeFalse(success.failed()); | ||
assertNotNull(success.permissions()); | ||
} | ||
|
||
@Test | ||
public void failedEmissionMustHoldDiagnosis() { | ||
Emission failure = failed(); | ||
assumeTrue(failure.failed()); | ||
assertNotNull(failure.failureDiagnostic()); | ||
} | ||
|
||
@Test(expected = Exception.class) | ||
public void successfulEmissionCannotHoldDiagnosis() { | ||
Emission success = successful(); | ||
assumeFalse(success.failed()); | ||
success.failureDiagnostic(); | ||
|
||
} | ||
|
||
protected abstract Emission failed(); | ||
|
||
protected abstract Emission successful(); | ||
} |
27 changes: 27 additions & 0 deletions
27
...org/eclipse/passage/lic/api/tests/conditions/evaluation/ExpressionFormatContractTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/******************************************************************************* | ||
* 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.conditions.evaluation; | ||
|
||
import org.eclipse.passage.lic.api.tests.registry.ServiceIdContractTest; | ||
import org.eclipse.passage.lic.internal.api.conditions.evaluation.ExpressionProtocol; | ||
import org.eclipse.passage.lic.internal.api.registry.ServiceId; | ||
|
||
@SuppressWarnings("restriction") | ||
public class ExpressionFormatContractTest extends ServiceIdContractTest { | ||
|
||
@Override | ||
protected ServiceId ofSameData() { | ||
return new ExpressionProtocol.Of("abra-cadabra"); //$NON-NLS-1$ | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...i.tests/src/org/eclipse/passage/lic/api/tests/fakes/FakeConditionExpressionEvaluator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.api.tests.fakes; | ||
|
||
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; | ||
|
||
@SuppressWarnings("restriction") | ||
public class FakeConditionExpressionEvaluator implements ExpressionEvaluationService { | ||
|
||
@Override | ||
public ExpressionProtocol id() { | ||
return new ExpressionProtocol.Of("brand-new-format"); //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public boolean evaluate(ParsedExpression expression, ExpressionTokenAssessmentService tokenEvaluator) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |
Oops, something went wrong.