summaryrefslogtreecommitdiffstats
path: root/models-tosca/src/test/java
AgeCommit message (Collapse)AuthorFilesLines
2021-03-04Merge "Refactor models for common type handling"Liam Fallon5-32/+58
2021-03-03Refactor models for common type handlingliamfallon5-32/+58
Currently we have handling for "type" and "type_version" on TOSCA Policy class. However, the concept of a "type" and "type_version" also exists on the ToscaCapabilityAssignment, the ToscaNodeTemplate, and the ToscaRequriement classes. This review makes the type handling on Policy generic, thus extending it to the other three types. Issue-ID: POLICY-2983 Change-Id: Ia20e3a8c485f4841257075df08e0784eac415770 Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-03-03Fix sonar issues on policy-modelslapentafd2-53/+56
Tests refactoring to reduce number of assertions to less then 25 Issue-ID: POLICY-3094 Change-Id: Icd3d83c7f8168dd81df13a584229eab36c646f37 Signed-off-by: lapentafd <francesco.lapenta@est.tech>
2021-02-19Refactor timestamp property in policy models to use Instantrameshiyer272-19/+20
Updated JPA classes to use java.sql.TImestamp rather than Instant. Issue-ID: POLICY-3069 Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech> Change-Id: If5b874ec96931d4b8dd142d46a9980e83a4708fc
2021-02-18Merge "Remove more duplicate code from models"Ram Krishna Verma3-97/+103
2021-02-17Remove more duplicate code from modelsJim Hahn3-97/+103
Addressed sonar "duplicate code" issue by extracting a common ToscaNameVersion class from the XxxIdentifier classes. Also removed junit test for class that no longer exists and renamed another junit to match the renaming of the class being tested. Issue-ID: POLICY-2905 Change-Id: I4a28cd7de2478f2771a864439c0b440ad8310299 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-02-17Fix sonars from removal of duplicate codeJim Hahn3-5/+339
The work to remove duplicate code from models introduced as many new sonars as it eliminated. :-( Addressed the following new issues: - visibility of constructor - use of more specific assertThat() calls Also added two junit test file that were somehow previously left out. Issue-ID: POLICY-2905 Change-Id: I7a0206bd157412d3c6d98bfe21797f106b37ac65 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-02-16Fix duplicate code in Jpa classesJim Hahn3-2/+264
Addressed the following issues: - remove duplicate code; extracted a common class containing properties Issue-ID: POLICY-2905 Change-Id: I80c423ab45c0c6823d338a034762d222ec334288 Signed-off-by: Jim Hahn <jrh3@att.com>
2021-02-07Make filters on TOSCA entities genericliamfallon8-221/+113
The classes PolicyTypeFilter and PolicyFilter only work on Policy types and policies. However they just filter on name/version/type/typeversion so there is no reason that the filters could not be applied to other entities. This commit adapts the PolicyTypeFilter to EntityFilter and PolicyFilter to TypedEntityFilter, so the filters can be applied to collections of any ToscaEntity class. Issue-ID: POLICY-2995 Change-Id: I8fcf76ee8c8497836b3286b35f928b0c341dac34 Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-01-28Add copy constructors to conceptsliamfallon2-0/+108
Copy constructors for ToscaServiceTemplate and ToscaTopologyTemplate. Issue-ID: POLICY-2971 Change-Id: Idb4abf8bce40593e0bf18614b8c647688dd5748d Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-01-19Merge "Add PfKey translation to ToscaConceptIdentifier"Pamela Dragosh2-4/+20
2021-01-18Create ToscaConceptIdentifier from ToscaEntityKeyliamfallon1-0/+1
THis change adds a method to create a ToscaConceptIdentifer from a ToscaEntityKey class. This method reduces the code vloume when translating between these identifiers. Issue-ID: POLICY-2971 Change-Id: Idd62339935d2ba78e6c60b40ee95fedac0642bef Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-01-16Add PfKey translation to ToscaConceptIdentifierliamfallon2-4/+20
Concenience constructor to create a TosaConceptIdentifier from a PfKey and a method to create a PfConceptKey from a ToscaConceptIdentifier. Issue-ID: POLICY-2971 Change-Id: I402b2e12cc11976cd7e98436eb46486c35fdaa31 Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-01-14Add copy constructor to ToscaNodeTemplateliamfallon1-0/+50
In order to support serialization and deserialization of ToscaNodeTemplate objects onto DMaaP, we need a copy constructor on the ToscaNodeTemplate object. Issue-ID: POLICY-2971 Change-Id: If6dc6c54d5673cef46734a88d0a91ae868c11dcb Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-01-06Changed identifiers to concept identifiersliamfallon4-41/+44
The policy models tosca classes ToscaPolicyIdentifier and ToscaPolicyIdentifierOptVersion can be used to identify any TOSCA concept, not just TOSCA policies so they are renamed to ToscaConceptIdentifier and ToscaCinceptIdentifierOptVersion respectively. The class ToscaPolicyTypeIdentifier is redundant and is replaced by ToscaConceptIdentifier. Issue-ID: POLICY-2900 Change-Id: Id0a37c42ea4e74f07b47e1694c4f8291c35879c9 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-23Add Service Template TOSCA handlingliamfallon4-31/+164
Today we can only handle a single service template in the database. We should be able to handle multiple service templates and assign arbitrary policy types and policies to maned and versioned service templates. This review brings in the Java API in models provider for handling service templates in this way and uses a simplistic single-teplate implementation in models-tosca, that will work but still only handles a single service template under the hood. Issue-ID: POLICY-2900 Change-Id: Ia02dea8abe44b7f407e685090a4b8e0360889653 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-21Use annotations to do validationJim Hahn1-1/+1
Modified models to use annotations instead of function calls for most field validations. Created a few new validation annotations for use within models. Per review comments: - renamed Key to VerifyKey - enhanced VerifyKey to imply "@Valid", unless disabled Issue-ID: POLICY-2648 Change-Id: I2b53f218b0a2ab1ed1f5e278816a3509f1408972 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-12-17Use ValidationResult for models v2.0Jim Hahn21-266/+273
Policy models uses PfValidationXxx classes which are totally unrelated to ValidationResult in policy common. This precludes the use of various utility methods and annotations for doing validation. Modified policy models to use ValidationResult instead. This approach uses function calls, though a future approach could make use of annotations instead. Issue-ID: POLICY-2648 Change-Id: I9760f1dc46902ab6bef7f440f3caf5e951660a5d Signed-off-by: Jim Hahn <jrh3@att.com>
2020-12-14JPA concepts for TOSCAliamfallon9-86/+295
Implement the Database persistence parts for the new TOSCA concepts so that those concepts can be written to and read from the database. First batch of comment fixes Issue-ID: POLICY-2900 Change-Id: I45191c1ff57cf1ea8563399db6cc8e51b2724813 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-03Add generic methods to TOSCA providers and utilsliamfallon3-0/+245
Generic methods for getting ehtire service templates are added to the TOSCA providers in models-tosca. These are needed to read service tempaltes containing entities that are not policy related. Issue-ID: POLICY-2900 Change-Id: If4c646037f51f8a18b66257426accc330905acf9 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-12-01Add extra authorative TOSCA conceptsliamfallon2-4/+4
This review brings in extra TOSCA concepts for Node types, nodes, and capabilities. The TOSCA handling is also amended to make the handling of equality consistent. Now, if filtering or ordering is required using an order rather than natural ordering, a comparator must be supplied by the user. Issue-ID: POLICY-2900 Change-Id: Ie40e86870b97eb993b1338bdc0666ac116f72f67 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-10-15Default should be an object on TOSCA propertiesliamfallon1-0/+57
Property default value is serialized to the database as Yaml and deserialized back into an object on a DB read. Issue-ID: POLICY-2844 Change-Id: I69f2843a93cd5f831359a0965223298b769498d9 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-08-24Merge "Remove legacy operational policy from models"Jim Hahn5-544/+6
2020-08-20Sonar Fixes policy/models, removing model-yamluj426b16-133/+149
Change-Id: Icd82ea1aef90e4d638b13958519aac5ed5a53f73 Issue-ID: POLICY-2714 Signed-off-by: uj426b <uj426b@att.com>
2020-08-19Upgrade new tcagen2 policy typePamela Dragosh7-15/+15
The old cdap policy type is deprecated by DCAE. Thus, we are simply replacing with the new tcagen2 policy type. Issue-ID: POLICY-2772 Change-Id: I1442340729b5f820f2e265b9b86f6f6f84f49bca Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-08-14Remove legacy operational policy from modelsRam Krishna Verma5-544/+6
Removing all the legacy operational policy related concepts, providers, examples etc from models repo. Issue-ID: POLICY-2764 Change-Id: Ie820271381674ccc4eaef0bd6379f673f67701e7 Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
2020-06-19Merge "Changes for Checkstyle 8.32"Ram Krishna Verma32-35/+0
2020-06-18Changes for Checkstyle 8.32liamfallon33-37/+0
Issue-ID: POLICY-2188 Change-Id: I6db16763c1d2d80ff934302081a8dfc16afa7d9a Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-06-18Replaced try/catch blocks in policy/models with assertj assertions.waynedunican1-8/+3
Issue-ID: POLICY-2451 Change-Id: I095beb674196d5ec5c4dd9b93d3a56cca5ee4788 Signed-off-by: waynedunican <wayne.dunican@est.tech>
2020-05-10Policy DB contents removed on DB deadlockliamfallon4-54/+61
When a DB deadlock occurs, the DB contents can sometimes be deleted becasue the DB removes the Service Template object and recreates a new one in two separate DB transactions. This change makes sure that the object remove and re-create is in a sngle DB transaction, so the operation will either happen or not happen so the DB will not be cleared. Legacy policy handling must also use the SimpleToscaProvider rather than accessing the DB directly, as SimpleToscaProvider keeps the DB structure correct. Issue-ID: POLICY-2548 Change-Id: I263a41cd1d8bec5d7b421045b3b14aad6e6c66d3 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-05-06Make type and type_version mandatory on policiesliamfallon2-8/+73
Up until now, the "type" and "type_version" fields defaulted to "NULL" and "0.0.0" respectively when they were not specified because the "type_version" field was not always specified on policies in previous releases. In cases where the "type_version" field was not specified, it was assumend that a "0.0.0" version of the policy type existed. In parallel, if the version field was not specified on the policy type, the version was stored as 0.0.0. This behaviour is now changed and the "type" and "type_version" fields are now always mandatory. Issue-ID: POLICY-2538 Change-Id: I4279adfa86f531205879dbb87986453604624032 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-04-16Add version to example yaml filesJim Hahn1-22/+7
Determined that some of the yaml files were not suitable for use in the CSITs, because they were missing the "version" property. Added it where needed. Also added type_version where it was missing, as well. Issue-ID: POLICY-2491 Change-Id: I47bf0ec2b99d29580390a6e90512dfd903b042d6 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-04-07Address sonar issues in modelsJim Hahn1-2/+2
Addressed the following sonar issues: - use RE2 instead of java.util Pattern for "+" and "*" - don't use deprecated methods - for Date(long), sonar appeared not to parse the argument's type correctly. Modified the code slightly to make sonar happy - duplicate blocks of code - either log or throw - missing assert in junit - for SDNR & VFC, eliminated threads, as they are unnecessary - duplicate code block in different branches - useless assignments - redeclaring abstract methods - cyclomatic complexity - used lombok in some cases (e.g., EqualsAndHashCode) - assert argument order - actually deleted ControlLoopTargetType, because it is not needed and sonar complains regardless of which order is used - add private constructor to utility classes - use StandardCharsets instead of literals Also: - added logback-test.xml to SO to eliminate the voluminous output from the junit test Issue-ID: POLICY-2305 Change-Id: I586c331781bedbd54a115a71847d04d293689445 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-03-25Cleanup eclipse warningsPamela Dragosh1-1/+0
Issue-ID: POLICY-2165 Change-Id: Iaad54af1b1210fe96fa44dcaa609834c46557877 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-23Add version to compliant operational policiesjhh1-7/+7
Issue-ID: POLICY-2356 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I5636ec4e92ff87fdefb9a6372a150ad021aeec16 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
2020-03-19Allow fetch of old policy type verisonsliamfallon1-53/+53
Due to the problems with TOSCA and version handling, the filtering for policy types on old versions did not work. This change fixes that problem. Issue-ID: POLICY-2377 Change-Id: I462bd5710b9dea37475861d1021d28b2c7391a24 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-03-09Add optional controllerName in Op. Legacy Policiesjhh1-1/+3
Optional controllerName has been added to Legacy Operational policies to be able to route Operational Policies to an specific drools controller. Currently, the policies are deployed to all controllers that support a policy type. In the case, that there are multiple controllers set, and the policy is only to be routed to one of them, this field should be populated. Issue-ID: POLICY-2388 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I7288ce0069a723b8e6ec535331dc9cda56fbf130
2020-03-06TOSCA Compliant Guard PoliciesPamela Dragosh8-572/+79
Fixing the legacy guard policies and renaming them so we are able to differentiate them. Adding newer, cleaner TOSCA Guard Policies that match the operational guard policies. Removing legacy guard policies. Fixing JUnit so that they don't use indexes to test whether versions are changed correctly. Added back in new guard policies. Fixed the guard policy types to use camel case. Issue-ID: POLICY-2243 Change-Id: Ie611f26f73f41e64c0b467f524f470739158f437 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-04Fix tca monitoring tca_policy typePamela Dragosh1-5/+1
Should not use map or entry_schema Issue-ID: POLICY-2408 Change-Id: Ieebe625676edab6c44323b7c69a50cc22099235f Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-03-03Return incoming service templates on createliamfallon1-3/+3
We should return the incoming service template on create requests. This change is required for CSIT tests. Issue-ID: POLICY-1402 Change-Id: I1072c9c16d2b267c34fa015e7e7a355ba9f5338a Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-18Add safe entity delete, fix multiple entity getliamfallon6-16/+340
This review implements checks on whether entities are being used or referenced propr to allowing deletes. The review also fixes bugs on multiple entity get returning 4040 not found Issue-ID: POLICY-1402 Change-Id: I9cebb9a873098740e9ff4be6284d6307e19838bd Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-17Add missing entry_schema for operational policy typePamela Dragosh4-16/+21
Also ensure the json for vFirewall matches the yaml. We will need to clean up some of the other legacy operational policies. Or at least rename them. Renamed legacy Operational policies to avoid confusion. Fixed wrong derived_from policy types. Operational Policy Types are now solely for new TOSCA compliant operational policy types. Issue-ID: POLICY-2146 Change-Id: Ia0bcabe6cca8e197f1bec8157a3004a420033969 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2020-02-13Update models-tosca for hetter handlingliamfallon4-21/+35
More additions, updates, and fixes for TOSCA service template handling. Better handling of 404 not found on list requests. Issue-ID: POLICY-1402 Change-Id: Id73b9a3cebb5445d4f05ae83e301330ee38a6598 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-12Implement validation and hierarchical getliamfallon7-79/+225
NOTE: This review will require changes to the persistence.xml file in other policy framework components. This change brings in two changes: 1) Validation of the references betwen policies, policy types, and data types This change mans that additions to and changes to policies, policy types, and data types must be structurally correct in the change coming in and with whatever is already in the database 2) Hierarchical return of referenced entitites on policy types, policies and data types. When a policy, policy type, or data type is read from the database, the entities referenced byt the returned policy, policy type, or data type are returned as well. Tests are amended for the stricter validation and structure. Examples are corrected where they are incorrect. Issue-ID: POLICY-1402 Change-Id: Ie6a4cb7ed336562338924079114df405f0ab889f Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-10Get the tree of parent entities for an entity in a containerliamfallon1-0/+123
Utilityu method to filter out all bit an entity and its parents from a service template entity container. Issue-ID: POLICY-1402 Change-Id: I8c3b4c21b27fd8787cdfde0e1b726646f52c437b Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-07Add data type and policy type reference checkingliamfallon7-113/+177
Full validation including references to policy types and data types added. Unit tests fixed to cope with new stricter validation. Issue-ID: POLICY-1402 Change-Id: I59f37640a99494a53960a54d2fc82cc96861d43b Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-05Add vaidation for entity hierarchiesliamfallon22-142/+400
This change brings in proper hierarchical checks for service templates, making sure that all parents of data types, policy types, and policies must be in place. Issue-ID: POLICY-1402 Change-Id: I61b1b556403f74aeaa092f0d4d6ed19bf6a0b715 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-02-04Add merge utility for service templatesliamfallon2-6/+212
This utility function allows a TOSCA service template fragment to be merged with an exsiting service template and will be tbe backbone of "create" methods on the API from now on. Issue-ID: POLICY-1402 Change-Id: I3381cb2a1bd30621a639dedc213c546eeb2bf9aa Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-01-28Merge "Add service template persistence provider"Jorge Hernandez2-0/+174
2020-01-28Add service template persistence providerliamfallon2-0/+174
Persistence needs to be carried out at service template level in order to guarantee consistency of the service template in the database as much as possible. Therefire, service template lelve reading, writing, and delting is required. Issue-ID: POLICY-1402 Change-Id: I5be57c29381bf6ddc87afdbb64ddae66a5ea5e5f Signed-off-by: liamfallon <liam.fallon@est.tech>