summaryrefslogtreecommitdiffstats
path: root/utils/src/test
AgeCommit message (Collapse)AuthorFilesLines
2020-01-27Schema validation extension to StandardCoderjhh5-0/+237
Issue-ID: POLICY-2331 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Ic3e8d21715d17a61ea5d07740dd9f4dd0dbb8641 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
2020-01-22Create path to text file being createdliamfallon1-1/+21
If you try and write to a file where part of the pat does not exist, that path should be created. Issue-ID: POLICY-1581 Change-Id: Ifb7a4ff4e1804814b6679956f0c58d5ac026c4a4 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-01-13Add method to return resource directory contentsliamfallon1-7/+42
In order to avoid hard coding the policy types and policies that are in the example directories into unit test cases, and in order to automatically pick up added and removed policy types and policies, it would be good to read the contents of resource directories at run time in unit tests. This change brings in that functionality into ResourceUtils. Issue-ID: POLICY-2315 Change-Id: I601718828aad0f065dbbaa1f5af8d0a0f133f44d Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-01-10Address items deprecated by move to java 11Jim Hahn1-2/+3
Addressed the following deprecated items: - "new Integer(xxx)" - Observable/Observer - Mockito.anyObject() Added assertion to a junit test to address a sonar issue. Did not address deprecated Nashorn javascript interpreter; that will be done in a separate review. Updated licenses. Issue-ID: POLICY-1406 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I81fd158f831e01d5410d79898ced658285787d47
2019-10-29Fix new sonar issues in commonJim Hahn1-2/+2
Issue-ID: POLICY-2204 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: If0a11913f614e038ecd3e8c3f0b56d3ac78b03ec Signed-off-by: Jim Hahn <jrh3@att.com>
2019-10-24Integrate CryptoUtils into ONAP commonChou, Joseph (jc2555)1-0/+105
Update junit to add test cases Change-Id: If3236853138a05faac5f51a859b935265c14f0d6 Issue-ID: POLICY-1945 Signed-off-by: Chou, Joseph (jc2555) <jc2555@att.com>
2019-10-21Add CryptoCoder interfacejhh1-2/+2
This is to allow multiple supporting implementations. Issue-ID: POLICY-1945 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I42491e5671f561fe320f034bf8ffe03848dff43f Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
2019-09-13Extract YamlJsonTranslator from StandardYamlCoderJim Hahn4-84/+210
Refactored StandardYamlCoder, extracting a new class, YamlJsonTranslator, from it. This facilitates performing yaml translation when not using a standard "gson" coder. Added YamlJacksonHandler which supports YAML translation layered on top of a JacksonHandler instead of a GsonMessageBodyHandler. Also added junit tests to complete coverage of StandardCoder. Also added public APPLICATION_YAML to YamlMessageBodyHandler. Change-Id: Ia470fa194661fbf1aebeaf0f18b57f2a984cb64b Issue-ID: POLICY-2081 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-12Remove YamlException classJim Hahn1-61/+0
After the implementation was finalized, it turned out that YamlException was no longer needed, so it has been deleted. Change-Id: Ie895fc096787f05eff36a6127b08247a7664ff8d Issue-ID: POLICY-2065 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-11Create StandardYamlCoderJim Hahn3-0/+233
Created StandardYamlCoder which is like a StandardCoder, except that the original converts to/from JSON, while the new class converts to/from YAML. Also added YamlMessageBodyHandler and incorporated it into the http server so that it supports a media type of */yaml. Change-Id: Ibd83a9f6d355a330f63e435f2bb41affcf1947c2 Issue-ID: POLICY-2065 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-08-14Add ApiUtils to facilitate looping over featuresJim Hahn1-0/+82
A number of places in the code (common & drools-pdp) loop over features, giving each provider a chance to act on something. Created a common method in a new ApiUtils class to faciliate it. Renamed to FeatureApiUtils per review comment. Change-Id: I0c2cf0f33854cb5b6921b394f64de498a6234909 Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-17Convert double to int when decoding via gsonJim Hahn1-0/+9
Refactored MapDoubleAdapterFactory, extracting DoubleConverter to be used by code needing to convert Double to Integer/Long after being decoded by GSON. Enhanced StandardCoder to automatically use the above converter if the desired class is a generic Object. Change-Id: I1d4e83910de41ceda383f257bfea706db2b8fbbe Issue-ID: POLICY-1919 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-05Fix sonar issue in common/utilsJim Hahn1-1/+1
Renamed a constant. Change-Id: I5e1f2fb6de8445a8f667ea48a595773173c6beae Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-26Speed up CryptoUtilsTestJim Hahn1-0/+2
CryptoUtilsTest runs slowly because the SecureRandom that CryptoUtils uses to generate an "iv" takes a while to create enough randomness. However, as the "iv" is only used as a "salt", it is not necessary to use SecureRandom; the values generated by Random are sufficient. Change-Id: I1f3b03b85d28852a7969d3a83802a2691308caa5 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-12Apply simple sonar fixesJim Hahn8-162/+167
Note: A number of these were identified, by SonarLint, in the Test classes, which are not typically scanned by Sonar. Removed unnecessary imports. Removed unneeded "throws Xxx". Replaced lambda with method references. Replaced duplicate strings with constants. Replaced try-fail-catch with assert-j methods to eliminate sonar complaints about duplicate failure messages. Added missing @Override annotations. Use map.computeIfAbsent() where appropriate. Also fixed some minor checkstyle issues. Removed unneeded "volatile" declarations. Replaced some if-else constructs with "?:" construct, per sonar. Replaced Object.wait() with CountDownLatch.await(); according to sonar (and javadocs), Object.wait() can return due to "spurious wakeups". Fixed issue whereby CryptoUtilsTest wouldn't run in my Eclipse. Change-Id: Ib6b71ed65662cfd6209400dac57ed69279bf29ec Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-11Don't map JSON values to DoubleJim Hahn1-0/+26
By default, gson treats all numbers as Double when placed into a generic Map. This is not backward compatible with existing policy APIs. Added a type adapter that walks Map objects and converts the Double values to Integer or Long, where possible. Made this the default behavior in the GsonMessageBodyHandler, the JacksonHandler, and the StandardCoder. Also fixed a couple of checkstyle errors in the gson project. Change-Id: I9ac0c77e6592d1c039646f0662c077b77a1e9aaf Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-04-04Add semantic version comparable classliamfallon1-0/+142
Class written by Jim Hahn that implements Comparable for comparing semantic versions. Lifted from policy models pap. Issue-ID: POLICY-1095 Change-Id: Ie8c5f9066c06cb569085e1390b3de3e4aa580267 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-03-21Add simple Registry class to manage singletonsJim Hahn1-0/+139
Typically, singleton classes have lots of static methods, or use a getInstance() method to get the singleton. This provides an alternative mechanism, similar to the JDNI and the common-paramater property registry, where singletons can be registered. Clean up registry after junit test. Modified a few comments. (I prefer 90 characters for comments.) Added a method to register or replace an existing key without throwing an exception. Change-Id: I3b62719013d3b5f71adb5e9299d3c1257fb55c80 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-20Add wrapper for ServiceManagerJim Hahn1-0/+115
This makes it easier for a class to implement a Startable interface, using a ServiceManager internally, while preventing other classes from adding services to the manager (as would be the case if the class were simply subclassed from the ServiceManager). Changed the field name to be more descriptive. Fixed a typo in a comment. Change-Id: I1bed6291114d21c20d2324cbda81518bf9183139 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-18Merge "Add Network Logging Feature"Liam Fallon4-53/+210
2019-03-16Make ServiceManager implement StartableJim Hahn1-8/+54
Also added a "name" to the manager, for logger purposes. Change-Id: Ide57cdec1fafc36c43b7f7584c0baad6261e8412 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-14Add support for TOSCA JSON Parsingliamfallon1-0/+53
Added a getter to allow the Gson object to be retrieved from a GSON message body handler, useful for testing. Moved the TextFileUtils utility class from APEX utilites to policy common utils Issue-ID: POLICY-1195 Change-Id: I7c8074e8177a90b292c6dfd6e7f0d352063818e7 Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-03-13Add Network Logging FeatureDaniel Cruz4-53/+210
This is part 1 of introducing the mdc filter feature. Network logging has to have interception points in order to pre/post process messages coming in from a network endpoint. The OrderedService interface and OrderedServiceImpl of the drools-pdp project have now been migrated to common but is also left in drools-pdp to mitigate disruption to existing features. However for features that need to use common's OrderedServiceImpl and drools-pdp version of OrderedServiceImpl there will be a conflict with getSequenceNumber(). So a migration of the other features is suggested. Network logging is moved to its own util class so that feature hooks can be invoked any time an event is being logged by a network logger. This util class will also be accessible to drools-applications in the case where drools-applications would like to invoke network logging features for REST events. Change-Id: I83d7c46e5abb351486f841c3be4d9009f7992476 Issue-ID: POLICY-1499 Signed-off-by: Daniel Cruz <dc443y@att.com>
2019-03-12Merge "ONAP password encryption tool"Pamela Dragosh1-0/+120
2019-03-12ONAP password encryption toolChou, Joseph1-0/+120
Migrate ECOMP Policy password encryption tool to ONAP Issue-ID: POLICY-1561 Change-Id: I9020efb7698b95c36c4ebff842a318bf8beefc69 Signed-off-by: Joseph Chou <jc2555@att.com>
2019-03-11Add ServiceManager classJim Hahn4-8/+357
Added ServiceManager class to start a list of services, in order, and stop them in reverse order. Also addressed minor checkstyle issue in TopicSinkClient. Enabled logging from tests. Updated some comments. Updated license date. Added state checks and support for multi-threading. Change-Id: Ie7f053d9884766fe199895691a57eb5a51b1d155 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-08Merge "Add code to allocate server ports"Jorge Hernandez1-6/+80
2019-03-08Add code to allocate server portsJim Hahn1-6/+80
Added code to find available server ports. Also added a trust manager that always trusts certificates. Made trust manager private so we can allocate new ones in the future, if we decide it isn't safe to re-use the same one over and over. Modified test code to allocate a port rather than assuming 8180 was not in use. Also modified retry parameters in other tests. Added another allocPort() that takes an IP address and then modified the other two to use that so the code does not have to be duplicated, while providing more functionality. Change-Id: I08cf18d923af46b1310d8496498bb1d4a0690b6e Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-07Remove PropertyConfiguration classJim Hahn1-1268/+0
Removed PropertyConfiguration class, as it has been replaced by the BeanConfigurator class. Change-Id: If97a74fe81875d3eb85d7775ce78a7f2b1fb1f70 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-04Add bean configuratorJim Hahn1-0/+1424
Refactored PropertyConfiguration, but left the original class alone until references to it have been removed from other policy repos. Split the Property annotation out into its own file. Cloned the remaining code into BeanConfigurator, modifying its behavior so that, instead of operating on its own subclass, it operates on a provided bean. Also added an ability to copy the bean's fields to a Properties object. Updated license dates. Removed unneeded argument from functional interface. Added comment about always checking default values. Updated a few comments. Change-Id: Iff36fd0524032d7630f9ee08f0eef7b05de100d1 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-03-01Add StandardCoderObject to hide GSON internalsJim Hahn2-0/+137
Added StandardCoderObject to hide GSON's JsonElement so that classes are not dependent on the use of JsonElement, making it easier to switch out serialization mechanisms in the future. Added a test for field-not-found. Converted tabs to spaces in json test file. Simplified StandardCoderObject and added methods to Coder for translating to and from StandardCoderObject. Removed a test for a method that no longer exists. Added more tests to a test case. Change-Id: I5123dc3f17c940ded431ef7f9ccd8c4bff6b1c5f Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-27Add additional encode and decode methods to CoderJim Hahn2-14/+141
Also: Updated some comments and renamed a few parameters. Removed a "throws" for a RuntimeException. Short-circuit some calls. Typo in comment. Let gson create the JsonWriter. Renamed a few more parameters. Change-Id: I22e48c2191820c2a3d0743200edca79bd74353e7 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-27Merge "Add common coder classes"Liam Fallon2-0/+145
2019-02-27Add common coder classesJim Hahn2-0/+145
Added coder classes as a common utility that can be used to encode and decode json data. Currently, it uses gson, but that can be changed. Separated the Coder interface from implementation. Used assertSame to compare references. Used numbers instead of strings so don't have to deal with escaping quotes in the test cases. Change-Id: Iea9001d2adc5a3150b3367619b5f43e96b5f8b41 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-26Assertion class for DAO codeliamfallon1-0/+98
This class is used by the DAO model code being moved from the APEX PDP to policy-models for generic DAO handling in the Policy Framework Issue-ID: POLICY-1264 Change-Id: I67cca540d9357f9ab16532090cb2edf397b332be Signed-off-by: liamfallon <liam.fallon@est.tech>
2019-02-14Sonar fixesJim Hahn1-2/+2
Added test for Serializer to increase junit coverage. Added tests for TestTimeMulti to increase junit coverage. Sonar fixes for PropertyConfiguration: - use equalsIgnoreCase - use the exception Updated license dates. Some fixes for LoggerFactoryWrapper to address sonar issue - utility classes should typically have a private constructor. Change-Id: I8957e9673fe8371ecca7abbb7ece87b0d6f46c1a Issue-ID: POLICY-1519 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-08Add superclasses for gson-jackson migrationJim Hahn1-202/+0
Added common classes needed by other gson-jackson code. Modified some logic to make it more maintainable or perform better. Updated comments and spacing. Fix another comment. Moved gson classes from utils to a separate gson project. Added GsonXxx annotations to mirror jackson annotations. Removed unneeded dependencies from gson pom. Removed old GsonMessage class from policy-endpoints. Removed trailing spaces. Updated licenses. Removed more trailing spaces. Removed unneeded checkstyle suppression file from utils. Change-Id: I1a285500faeb0a0b6a1467d09b92ecd3cded713e Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-05Skip all fields in gson by defaultJim Hahn1-0/+202
Created an exclusion strategy that will prevent gson from serializing any fields within a class. The strategy must be registered to take effect. Uses lists to identify classes to be excluded when using gson with the jackson default behavior. Change-Id: I747fb1159846ad3000f69603f9b5d3f03bc8764f Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-01-30Add helper class to retrive network loggerKrzysztof Opasiak1-0/+52
Instead of defining static string variable inside Topic class let's create helper class for getting specific loggers. Issue-ID: POLICY-1486 Change-Id: Ic1f07466e1ab6abcc00098e617f0e82da19e852d Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2018-11-26Rename test classes in policy/commonParshad Patel6-6/+6
Make test classes name consistence Issue-ID: POLICY-1281 Change-Id: I2d70eda0a2fe7dc60e020dd91c743c1708d1f11a Signed-off-by: Parshad Patel <pars.patel@samsung.com>
2018-09-26Use powermock version from parent pomJim Hahn1-1/+1
Change-Id: I84fd562e7050508a75b4192ba162a09acd938986 Issue-ID: POLICY-1148 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-08-22Adding common utility classes to policy/commonramverma1-0/+57
* Adding HealthCheckReport class to policy/common for wider use among all policy modules. * Adding utility class called ParameterValidationUtils for providing common validation methods to all policy modules. For now, it has only 3 validation methods but we all can add more in future. Change-Id: I363fe116ba74f25299fd71211be73505b3164f72 Issue-ID: POLICY-1035 Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
2018-08-13Fix checkstyle in utilsPamela Dragosh9-66/+94
Cleared all the checkstyle in these 2 submodules. Issue-ID: POLICY-881 Change-Id: I248e1894aebf549d5a4f8669a6466ec227d40b55 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-07-31Add resource handling utility classliamfallon2-0/+327
Add ResourceUtils, a class that provides utility methods for dealing with Java resources on the classpath. Change-Id: Ie4df249315ad145aabdfb35bb827ffbf6d79e095 Issue-ID: POLICY-922 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
2018-07-25Copy policy-endpoints from drools-pdp to commonmmis1-0/+40
Issue-ID: POLICY-967 Change-Id: I374c155ee102c3e157c60d0a22d7191544abb76a Signed-off-by: mmis <michael.morris@ericsson.com>
2018-06-21Merge "Delete SpecPropertyConfiguration class"Pamela Dragosh1-411/+0
2018-06-20Merge "Add CurrentTime utilities"Pamela Dragosh1-0/+59
2018-06-20Delete SpecPropertyConfiguration classJim Hahn1-411/+0
Change-Id: Ie97d2c396ec6df1e03287a7ecb866bc8acf6cfbc Issue-ID: POLICY-907 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-06-19Add CurrentTime utilitiesJim Hahn1-0/+59
Add some comments. Update license text. Change-Id: I4cee208378c44d9730274aee337feb95f9026add Issue-ID: POLICY-908 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-06-19Merge "Move SpecProperties from drools-pdp to common"Pamela Dragosh1-0/+224