aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java
AgeCommit message (Collapse)AuthorFilesLines
2019-06-04Undeploy policies when subgroup is deletedJim Hahn1-0/+48
When a subgroup is deleted via the PDP Group create/update API, any PDPs in the subgroup should have all of its policies undeployed. In the process, refactored addOrUpdateSubGroups() out of updateGroup(). Change-Id: I0750802bfb133a655e38493a868744b512ca3fb4 Issue-ID: POLICY-1803 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-05-10Return 200 when policy successfully undeployedJim Hahn2-4/+17
The PAP Undeploy CSIT was failing, because it was returning 400. The code was counting PDP UPDATE requests to determine whether or not the policy had been found. However, if a subgroup currently has no PDPs assigned (as is the case with the CSIT), then there will be no PDP UPDATEs, thus it will think that the policy was not found and return 400. Modified the code to count updates to the DB instead. Change-Id: I80cdcc738e07c418e0a7184284e7a228e3a6014d Issue-ID: POLICY-1758 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-05-09Return error when deleting non-existent policyJim Hahn4-16/+27
When undeploying a policy, if a policy's type is found in a group, but the policy is not, then PAP returns 200. It should return an error instead. Change-Id: I88273fdbd5d49095e8248ab9267cccc529af0ae0 Issue-ID: POLICY-1758 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-30Cancel PDP timers in PAPJim Hahn1-0/+11
When a response is received by PAP from a PDP, the associated timer (and listener) are not being cancelled. As a result, when the timer later expired, PAP was re-sending the request. Modified the code to fix this. Change-Id: Id63f76622c01d286c169b618f8369b849ff31085 Issue-ID: POLICY-1715 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-24Validate supported types3.0.2-ONAPJim Hahn4-4/+85
When a group is created, PAP should verify that the "supported types" exist in the DB. Address potential sonar issue. Address potential sonar issue in similar block of code. Change-Id: Ib830550bc37d4ebe42c8782f3f874e463f3f51c2 Issue-ID: POLICY-1688 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-23Return appropriate HTTP status codeJim Hahn8-183/+143
Return 404 instead of 500 when items are not found. Bubble up other HTTP error codes instead of changing them all to 500. Change-Id: Ib614bb83f28cfb1ce2384679398f0a45058fc455 Issue-ID: POLICY-1686 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-20Merge "Handle null policy lists"Jorge Hernandez1-0/+41
2019-04-19Add end-to-end junits for PAP REST APIJim Hahn12-171/+1483
Added test that checks sunny day scenarios for the PAP REST API. Uses real PAP components for everything except DMaaP. PDPs are simulated. Change-Id: If2adc3b1523b477c3efd3eb83fb7a7b04f40fa24 Issue-ID: POLICY-1670 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-19Handle null policy listsJim Hahn1-0/+41
UpdateReq throws NPE if the policy list in the request or the response is null. Change-Id: I0d71d6ad4cc9b96315c3b3ba89af8e4d8f3f94e6 Issue-ID: POLICY-1669 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-16Clear servlets at the start of testsJim Hahn3-0/+7
Modified the junit tests to destroy the servlet factory before each test to prevent previous configurations from interfering with new configurations. Change-Id: I558269e89af271bee13cb9db94eadbcbf08f14d4 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-15Fix sonar issues in PAPJim Hahn1-1/+1
Moved methods into nested class of PdpModifyRequestMap. Note: they will have to be moved back out when the broadcast capability is added. Removed extra "continue" from Publisher. Rather than remove unused parameters and cause significant clutter to the code, chose to use the parameters in a logger call for RequestImpl. Removed unnecessary cast from UpdateReq. Use version constant in PapRestControllerV1. Log exception in PdpGroupQueryControllerV1. Log exception in PdpGroupStateChangeControllerV1. Shortened functional in PdpGroupDeleteProvider. Removed unnecessary type parameters from PdpGroupDeployProvider. Removed unneeded parameter and exception from ProviderBase. Extracted common string from Main. Shorted functionals in PapActivator. Changed uses of getCanonicalName() to getName(); the former only has limited use, while the latter is typically what is wanted and is actually required whenever forClass(name) is used. Fix junit tests broken by rename of ToscaPolicy version from "typeVersion" to "type_version". Change-Id: Ia00e1b3541c9e25b196a951e45681f67aa7f1bfe Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-15Support integer policy-versionJim Hahn5-81/+70
The deploy/undeploy APIs used by CLAMP only pass the major number when specifying a policy-version. Modified the code to handle policy-versions of the form, major or major.minor. Change-Id: I3251df162984f287bd1430b8e46da675b4c265ee Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-13Support group-oriented REST APIJim Hahn6-62/+751
Added code to support PDP group create/update & delete REST API calls. The create/update request can also be used to deploy/undeploy policies. It is assumed that the create/update request specifies a valid list of supported policy types for each subgroup (i.e., PDP type). Updated due to elimination of "version" from group in policy/models. Added/updated junits. Change-Id: I1916d9b17dfd5f12129c6f6a2fcf54e706662c10 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-12Update PDP with null group/subgroup when disabledJim Hahn3-10/+45
Modified the code so that, when a PDP is unable to fulfill a request, an UPDATE is sent to the PDP with group=null and subgroup=null. Also made updates to eliminate group version due to changes in policy/models. Change-Id: I9400ef5f8c365f492113a5b592b9ee6b7218756e Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-11Adding code for db config & initial group creationramverma1-0/+1
1) Adding code for initial PdpGroup/Subgroup creation. 2) Adding db configuration 3) Updated code as per change in policy/models Change-Id: If37870925001b333e0537e364eecb266c351cf5a Issue-ID: POLICY-1635 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
2019-04-11Don't change group version numberJim Hahn6-185/+41
Modified code to update a PdpGroup, adding or removing policies, without changing the version number. Change-Id: I10031dff5f6d9c7e568605a8d73af6fe3c740901 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-10Remove PDP from all active groupsJim Hahn2-36/+0
The code to disable a PDP used the group name, extracted from a prior PdpUpdate request, to identify the group from which the PDP should be removed. This is not sufficient, as the requests tracker may have never seen an update request. Therefore, the code was modified to simply remove the PDP from all active groups. Also made removeFromGroups(pdpName) public so that it can be used by other PAP code. Change-Id: Iedec88cb23e586944563dcc5ac82ff3b9f122f8c Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-10Merge "Add junit tests for PdpGroupDeleteProvider"Jorge Hernandez3-11/+269
2019-04-10Merge "Refactor request map"Jorge Hernandez12-1270/+1885
2019-04-10Add junit tests for PdpGroupDeleteProviderJim Hahn3-11/+269
Change-Id: Id744a7d49b9fb608ba3379dd43bcbd6a0297891f Issue-ID: POLICY-1541 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-10Current draft of undeployJim Hahn1-9/+10
Change-Id: If3f01a6e92bef9eb889066115537f599e6b09229 Issue-ID: POLICY-1541 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-09Refactor request mapJim Hahn12-1270/+1885
Refactored to facilitate the addition of broadcast requests in the future. Added disable-PDP capability. Updated some comments. Add junit tests. Only treat null group as broadcast - empty strings are not broadcasts. Added more logging. Change-Id: I6f62b8755d20769c333f06752e9d63ac9ed83b57 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-09Adding PdpGroup query & statechange providersramverma1-2/+3
1) Adding implementation of PdpGroup Query & State change providers for PAP REST API. 2) Adding support for unregistering Pdp after recieving TERMINATED state in PdpStatus message. 3) Updating PdpStatusMessageHandler with new filter changes in models. 4) Removing updatePdpStatistics method as we will implement db provider and REST provider in next release. 5) Fixing few bugs found during Pdp registration testing. 6) Updating the existing test cases to work. 7) Will be adding more exhaustive test cases in another review. Change-Id: I7aa20bf422671fdc1e06dab5e90aef4ee19a6a02 Issue-ID: POLICY-1541 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
2019-04-05Delay DB updates until all policies processedJim Hahn5-66/+302
If an exception is thrown in the middle of processing policies, it's possible for the DB to reflect a partial deployment. This change queues the DB changes so that they're all made at once, after all policies have been processed. Extracted sort() into a common place. Corrected some comments. Simplified the list retrieval in the junits since all DB creates and updates are now batched together into one operation each. Change-Id: I835175fc16d4042c741d36ec69caa8f603d46d5a Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-05Flesh out policy deployment REST APIJim Hahn8-111/+1161
Also moved the controller, the provider, and supporting classes to their own dep_undep package. Change-Id: Ifea1c4dd2ecbf93a8f4d45e130830cf9271103d3 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-05Fixes per latest models updatesJim Hahn3-15/+9
Changes made per the scrum call on 4/4 moved things around. In addition, filter classes were added to the tosca provider. Both of these necessitated changes to policy/pap so that things compile. Change-Id: Iba4c52b650dab0f8d242b06be3fede42dd5b7264 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-04Adding more code to pdp registration handlerramverma1-8/+8
1) Adding more code to pdp registration handler. 2) Fixing few broken files. Change-Id: Ic8b68f95f7022ce0572345ea358ff380ec8a3e61 Issue-ID: POLICY-1443 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
2019-04-03Fix classes in pap to align with change in modelsramverma5-426/+42
Change-Id: I0ecef8f004967e2fffa33eff2ee7e6f035d3d94c Issue-ID: POLICY-1443 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
2019-04-02Remove pdpType from testsJim Hahn2-2/+0
Somehow, pdpType is was still referenced by junit tests. Thought I had fixed that, but guess not. Change-Id: I8060208129cb2c6ba1ecb21d65efb778a2778aa5 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-01Add mapper classJim Hahn4-12/+503
Added class to map between classes in models-pap and models-pdp. Used constants in appropriate places. Re-use maker functions. Added some comment. Corrected a comment. Added mapping method for PdpDeployPolicies. Added PdpDeployPolicies to "internal" package. Updated to reflect refactoring of ToscaPolicy. Fixed bug/typo in assertEquals test. Updated tests to work with models-pdp not based on PfConceptKey. Change-Id: I31cd4aaf58fa7dc39cea76349cc1337637a1b786 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-29Fix issues with timer manager junitsJim Hahn1-74/+76
Attempt to fix intermittent issues with junit tests for timer manager. Eliminated duplicate method in junit test and renamed another method. Always release a semaphore, just to be sure. Logged different message depending whether timer is cancelled or expired. Locked access to the current time to prevent the timer thread from accessing it while registering a new timer. Change-Id: Icb499acb18197fd8042eb186f88b61d5c30daeb0 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-27Adding db provider parameters to pap config fileramverma1-14/+40
Change-Id: I573a345bcf69eb40782277f211fff2b7c69c4f55 Issue-ID: POLICY-1443 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
2019-03-27Add and register DAO provider wrapperJim Hahn1-0/+3
Added a DAO provider wrapper supporting a single create() method to create a DAO provider. PapActivator registers it at start-up. Commented out some junit timer tests that seem to fail intermittently - doesn't impact code coverage. Removed TODO from close() method. Change-Id: Ie3abd7c7a4f9ffa7aa086609515a0bb3891585d9 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-26Add components for PDP communicationJim Hahn12-0/+2504
Added PAP DAO interfaces. Added Publisher. Added TimerManager. Added RequestDataParams. Added PdpModifyRequestMapParams. Added RequestData. Added PdpModifyRequestMapTest. Updated timer test. Extracted nested MessageData classes into their own files. Addressed merge conflict. Removed unneeded methods from PapActivator. Fixed mismatchint action name. Change-Id: I3aebef68a62b48d9154dd7a4c4ff366f9914717c Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-25Changes to PAP infrastructure to support PDPJim Hahn12-69/+413
Modified PapActivator to implement the Startable interface and used that to manage it instead of the original method names. Replaced pdp-common enums with models-pdp enums. Added the use of the Registry. Added parameters to be used for PDP interaction. Added DAO interface classes. Modified HTTP client, in junit tests, to use GSON instead of Jackson. Removed DAO code, as the interfaces are not merged into policy/common yet. Added pdpParameters to default json config file. Changed tabs to spaces in json files. Removed "internal" classes that were moved to models-pdp. Change-Id: I969a7747e926680ad403557b44a0a52d289fb6d9 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-20Adding query & state change PAP REST API'sramverma3-11/+142
Change-Id: I861ace4811032314c3ce2c3f227f17354e127e5e Issue-ID: POLICY-1541 Signed-off-by: ramverma <ram.krishna.verma@est.tech>
2019-03-16Merge "Add additional constructors to Exception classes"Jorge Hernandez1-10/+7
2019-03-15Updates to PDP deploy/undeploy per Ram's commentsJim Hahn1-2/+2
Change-Id: Ic038ec8571cb50918c5f0d63602112ca05233629 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-15Add additional constructors to Exception classesJim Hahn1-10/+7
Modified test class to use auto-tester. Updated comments. Updated licenses. Change-Id: I993d0b78f31d15e6e6c35b701ed801616708628a Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-13Add simple deploy/undeploy REST APIJim Hahn2-12/+90
Change-Id: I4b789bfe4f92dae930f3675c6648b90f3c9fc9e4 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-13Add PDP Group Deploy and Delete REST API stubsJim Hahn13-269/+386
Note: this will not build until the models-pap code has been added. Added PDP group Delete methods, with and without version. Added checks for OK status codes. Added topic configuration. Still does not have the "simplified" PDP Group deploy/undeploy. Still won't build without "Move PDP Group classes to concepts subdirectory". Will add junit tests for code changes in another review. Updated comments about unlocking after updates. Made ServiceManager final. Included topic start/stop actions. Fixed parameter comment. Removed unneeded parameters from json files. Fixed argument test in shell script. Updated licenses. Change-Id: I6176d51918ae758e04fb68562dc9ca70534137d4 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-07Refactor REST server testsJim Hahn8-331/+521
Refactored the REST server tests so that each controller has its own test class. Also ensure things are shutdown by various tests. Added comments. Removed unneeded constant. Updated license. Modified code that restarts the REST server during tests. Modified code to just change the activator's "alive" state to false, leaving the REST server running. Fixed comment. Allocated server port. Removed file that should not have been included. Changed code to throw exceptions if activator methods are called while in the wrong state. Change-Id: I04a3a6654150797c23b3c86a6a39ecf8bb7f5a78 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-06Use request id instead of PDP name in listenerJim Hahn1-29/+83
Modified the listener that receives messages from the PDPs to use the request id instead of the PDP name for tracking purposes. Modified the listener to make it more generic so any arbitrary ID can be used, depending on the context. Combined extractId into handleEvent. Corrected a comment. Change-Id: I6b7097c67d73f51b78ae4063341bcb118eb14bbc Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-04Receive PDP status messagesJim Hahn2-0/+178
Added infrastructure code to facilitate receipt and tracking of PDP status messages. Removed temporary PdpStatus class. Use variable for pdp-common version. Change-Id: Id76c45f26b6d9f5eb9395332b637a0b1e90bc496 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-28Merge "Use Coder class"Jorge Hernandez1-4/+8
2019-02-28Merge "Add code to publish to PDP"Jorge Hernandez2-0/+175
2019-02-27Use Coder classJim Hahn1-4/+8
Modified existing PAP code to use the Coder class instead of Gson. Change-Id: I770d0adf201d7c1118085f85c36582e1143deb08 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-27Add code to publish to PDPJim Hahn2-0/+175
Added code to take an arbitrary object and send it to PDPs using a topic sink. Does not include the code or properties needed to configure the topic. Fixed method name - test case does not cover what the method name implied. Fixed some comments. Add test to verify that the PdpClient works with a real TopicSink. Moved coder classes to policy/common. Change-Id: I4dec746b07d384c5d9d1449ca91fa39a4f680260 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-25Replace static methods with single getInstanceJim Hahn3-39/+140
Some of the PAP classes use a number of static methods. These have been modified to use regular, non-static methods, a single static method, getInstance. Also modified PapStatisticsManager so its methods are thread safe. Changed "instance" to "current" for the activator, as it may be changed. Fix new checkstyle issues. Updated copyrights. Renamed test class to be consistent. Added test for getCurrent/setCurrent and isAlive. Change-Id: Id6df55fa4c116852032ad61f80f899fcd292f864 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-21Add swagger annotations to PAP API'sramverma1-4/+4
Change-Id: I2adafa5957bb4ede76196c6ac887a45b3375ce48 Issue-ID: POLICY-1480 Signed-off-by: ramverma <ram.krishna.verma@est.tech>