aboutsummaryrefslogtreecommitdiffstats
path: root/policy-core/src/test
AgeCommit message (Collapse)AuthorFilesLines
2020-04-06Address sonar issues in drools-pdpJim Hahn4-10/+13
Addressed the following sonar issues: - add "final" to public static fields - commented code; some were bogus - just updated the comments so sonar is happy - use "{}" instead of string concatenation - junit should assert something - when using logger, invoke compute-intensive tasks conditionally - use superclass name instead of subclass name to access static fields - don't always return the same value - remove "transient" from fields of classes that aren't Serializable - don't nest try/catch blocks - use appropriate class name in Logger.getLogger() - use Predicate<T> instead of Function<T,Boolean> - remove unused parameters from private methods - either log or throw - remove duplicate methods - use remove() TLS instead of set(null) - null check is implicit in instanceof check - do something with return value - don't use volatile - don't return "null" list; used Optional instead - add no-arg constructor to non-Serializable superclass - add callSuper=true for EqualsAndHashCode - don't declare "throws XXX" where XXX is a subclass of RuntimeException - remove serialVersionUID field if the class isn't Serializable Also addressed some eclipse warnings: - unused fields - suppress generic typic cast warnings Issue-ID: POLICY-2305 Change-Id: I906d5bf71c1f86531423e23b3667a585cdba45e1 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-02-25Add DroolsExecutor for DroolsRunnableJim Hahn1-13/+28
Added DroolsExecutor, which is an Executor that works by injecting its commands into drools working memory via DroolsRunnable objects. Issue-ID: POLICY-2385 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I59a57bc431249c84cb08f87089f6239993d7d2c4
2020-01-13policy/drools-pdp jdk11 upgradesHockla, Ali (ah999m)3-8/+10
Issue-ID: POLICY-1589 Change-Id: I0ed05c6e471a7da6658e02a4ba3115d3a117cedd Signed-off-by: Hockla, Ali (ah999m) <ah999m@att.com>
2019-11-14Add 'DroolsRunnable' classStraubs, Ralph (rs8887)2-1/+73
This provides a simple way to run arbitrary Java code within the Drools thread. This change also includes a general way to specify Drools rules that are automatically added to every Drools session. Change-Id: I5ddcca4c807dc552fbcbd4a19dce311a4d358279 Issue-ID: POLICY-1948 Signed-off-by: Straubs, Ralph (rs8887) <rs8887@att.com>
2019-11-06Drools Controller upgrades Testsjhh2-3/+125
Issue-ID: POLICY-1407 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I6963fced5608b62a41b73fef5070c21cf45d6fbe Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
2019-10-17Reimplement Lock API using Lock objectsJim Hahn6-1348/+367
Modified PolicyResourceLockManager to just return a feature, deferring the lock() call/method to the feature, itself. The manager was also modified so that, if it can't find an enabled provider, it will return a default provider, whose lock() methods always fail. Once a feature has been identified, the manager will cache it for use thereafter. Modified the feature API to return lock objects and simplified the interface to remove the beforeXxx and afterXxx methods. Moved the unlock and refresh methods from the feature API into the lock class, renaming them to free and extend, respectively. Added a separate, feature-simple-locking project, which implements a simple version of the locking feature, over a single JVM. Extensively revised the distributed locking feature to fit in with the new API. Added support for persistence so that the various LockImpl classes can be serialized and still function correctly when they are deserialized back into new feature instances Added default implementations of free & extend to LockImpl. Modified API to take the ownerKey string, instead of the owner object. Removed Extractor as unneeded - may add via another review, if still useful. Updates per review comments: - Updated licenses in feature-simple-locking - Added beforeCreateLock & afterCreateLock to feature API - Moved SimpleLockingFeature into policy-management so that it's always available - Moved the executor service, "exsvc", into PolicyEngine - Moved Extrator into policy-utils - Changed Extractor logging level for exceptions - Fixed feature sequence numbers - Fixed mixing of seconds and milliseconds - Renamed exsvc - Modified to use property method with default value - Configured scheduled executor - Added suffix to Extractor.register() - Eliminated Feature Api and tied lock manager into engine - Added non-null checks to LockImpl parameters - Added non-null checks to createLock() parameters - Checked that lockManager is initialized Change-Id: Iddba38157ddc5f7277656979c0e679e5489eb7b1 Issue-ID: POLICY-2113 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-16Fix checkstyle issues in policy-coreJim Hahn3-4/+4
Also deleted the checkstyle suppression file. Change-Id: I93e9f9154b614b56f7826ec978e1a99bd9369348 Issue-ID: POLICY-1907 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-01-08Replace expectException with AssertJJim Hahn3-101/+32
Change-Id: I5c9c5e962a7e2a5617405d534c0719f4bdb6ff1c Issue-ID: POLICY-1393 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-11-29Remove Factory from various drools-pdp classesJim Hahn1-24/+3
Also merged changes from 'Rename test classes in drools-pdp'. Change-Id: I4d0a3a1b0b5523eadf38d1edb5aa86c404b69d19 Issue-ID: POLICY-1288 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-10-05Add coverage to policy-coreJim Hahn6-65/+361
Added easy junit test coverage cases. Fixed sonar issue: removed sleep from DroolsContainerTest. Fixed sonar bug in ClassExtractors. Change-Id: I942badf17c42346c1735bc3951450fc31c02a769 Issue-ID: POLICY-1148 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-10-01Set drools-pdp checkstyle configPamela Dragosh2-12/+12
Fixed last remaining checkstyle issues along with setting the pom.xml to the correct path setting. Fixed forbidden summary fragments, not allowed to prepend summary with "This method returns" Issue-ID: POLICY-1153 Change-Id: I267842080494132a7b5507731e14f027a3f6fe44 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-09-21new sonar issues in drools-pdpJim Hahn3-13/+13
No "@Test" methods - renamed class from XxxTest to XxxMock. Changed functional call syntax. Change-Id: I954c2549705e80c00aed8ecbcb19f386cc8b0310 Issue-ID: POLICY-1137 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-09-10Fix checkstyle policy-corePamela Dragosh10-508/+481
Working on the policy-core submodule in drools pdp. Issue-ID: POLICY-882 Change-Id: I58d418110fe0fda90f97117ef17edfc13d648ccc Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-07-18Deny subsequent lock()Jim Hahn1-2/+2
This is the final step of separating the lock "refresh" operation from the original "lock" operation. This step entails rejecting subsequent "lock" requests, even by the same owner, when a resource is already locked; "refresh" should now be used, instead, to extend a lock. Modified comments to indicate that the lock can only be extended using "refresh". Change-Id: I406cf60c076dbce87afbd94fb301732359dbd2db Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-07-16Distinguish lock from refreshJim Hahn3-2/+207
This is the first step of separating the lock "refresh" operation from the original "lock" operation. This step entails adding the refresh() method to both the default and the feature-distriubted locking mechanisms. Change method call, in junit test, from lock to refresh. Change branch name in git review. Change-Id: I506de7a96cb3ee786839aca04ad67cdd7378832c Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-06-27Add time limit to locking facilityJim Hahn4-503/+108
Modified the locking facility to add a time limit and remove the callback parameter. This affected both the default facility as well as the distributed locking feature. It will also require a change to the rules for Closed Loop. Changed testUnlock() to try locking with a different owner. Default feature API should be OPER_UNHANDLED. Put a few things back so-as not to break the drools-applications build. They can be removed once drools-applications is updated. Fix newlines in API java. Change-Id: I3ed7835cac6a582493a9bc8f6d1d4f3e6cb6289e Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-06-25Added expiration timer to default locking strategyJim Hahn3-5/+167
Fixed comment (missing "}"). Changed default age from 15 hours to 15 minutes. Only increment test time by 1 when testing hashCode. Change-Id: I70ef6cfd34e31ded45b3975f33e5b0ba22afa627 Issue-ID: POLICY-912 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-06-18Add setXxx methods for @Property annotationJim Hahn1-38/+9
We'll be modifying the PropertyConfiguration class so that, instead of directly setting values in private fields, it will use public setXxx methods. Consequently, we have to add the setXxx methods to the PropertyConfiguration subclasses so that they're available when the superclass is modified policy/common. Change-Id: Idff9942eabec182670cbb427b960f6308a2ca30c Issue-ID: POLICY-906 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-04-16Merge "Sonar fixes to pooling"Jorge Hernandez1-0/+85
2018-04-16Sonar fixes to poolingJim Hahn1-0/+85
Made various changes to the pooling feature to address some of the sonar issues. Remove duplicate classes, Pair & Triple. Fix sonar issue about duplicate process(xxx) methods. Remove extra items from pom.xml and add assembly builder. Fix license text in pom.xml, inadvertently reformatted. Fix a few typos in comments and change LinkedList to Queue. Move assembly.xml to correct source directory. Replace ScheduledFuture<?> with CancellableScheduledTask, to satisfy sonar. Eliminate "TODO" items: add logging, delay after sending Offline message. Add more logging in process(Message) methods. Begin creating end-to-end junit test, fixed bugs found as a result. Restore logback-test.xml to WARN. Fix merge conflict - restored test properties file. Change-Id: Ic70a8cee49678ea0fc3da309699aec1f6088fe70 Issue-ID: POLICY-728 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-04-16Add missing licensesPamela Dragosh2-1/+39
Adding missing licenses to files that should not harm compilation, JUnit tests and instantiation. Issue-ID: POLICY-741 Change-Id: I3075e3493676ee28693323f978c0b5b210b20a34 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-04-12Sonar fixes for policy-core locksJim Hahn5-109/+69
Made a number of changes to the locking code in policy-core, to address sonar issues. This entaileed changing some of the Lock API methods to return OperResult instead of Boolean. Updated distributed locking with the new API return types. Simplified Thread creation using functional methods. Change-Id: If32bf7a435d2aedb969de1b77c7e7e27e110ecb0 Issue-ID: POLICY-728 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-04-03Add api-resource-locks featureJim Hahn6-0/+1486
Added ResourceLockFeatureAPI, to provide an interface for PolicyGuard to use to access other locking mechanisms. Move lock API to policy-core. Changed the interface and added Callback support. Added a class to invoke the API implementers. Changed to set a future instead of expecting the callback to implement the future interface. Also refactored, creating "lock" sub-package. Add junit tests. Increase junit coverage. IsLocked & isLockedBy should check all arguments. Make ImplFuture protected instead of public. Simplify locking - move callback support to an optional feature. Move Reference class to policy-utils. Return plain Future instead of LockRequestFuture. Change-Id: I65154d33833914b4332e02d1ef2512f4c5f09b16 Issue-ID: POLICY-577 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-02-08programatic install of rules artifacts for junitsJorge Hernandez7-2/+158
instead of relying on pom.xml, build settings. since jenkins jobs that generate sonars don't seem to go through a build phase anymore, therefore the preceding artifacts are not available in the local repository, which is required by the tests. Change-Id: Icfd14b2f8a6c6e1ac7d986bd6eb977b2a83b044d Issue-ID: POLICY-621 Signed-off-by: Jorge Hernandez <jh1730@att.com>
2017-10-09send messages directly through topicJorge Hernandez1-4/+2
This work is needed for consolidating the amsterdam templates used both for junits and the official one from the archetype into one, so junits can run in the official one. This work revisits the functionality of when a drools controller cannot be found to check state before delivering a message from the drools application, it will use a standalone enconder (previously configured to do so). This was intended to work like this originally, but never tested nor used as all deliveries are send through the controllers so locked/alive state is checked (but there may ocassions where we want to take this default action). Change-Id: Ie23e4e13323f3ab9fd207f8a396c1af6564b7edf Issue-ID: POLICY-101 Signed-off-by: Jorge Hernandez <jh1730@att.com>
2017-09-18Add Junit tests to 'policy-core'Ralph Straubs3-0/+492
These tests focus on the following classes: - PolicyContainer - PolicySession - PolicySessionFeatureAPI 'maven-invoker-plugin' was used to compile and install artifacts for testing during the 'test-compile' phase. These aren't part of the Maven project hierarchy, so they aren't visible to Sonar and SonarQube, and they aren't deployed. Change-Id: I67c122debbe5280f0153e7330248dc5d13c5b2c0 Issue-ID: POLICY-236 Signed-off-by: Ralph Straubs <rs8887@att.com>