* @param arguments output arguments
* @return
*/
- public static String formatMessage(String format, Object ...arguments) {
+ public static String formatMessage(String format, Object...arguments) {
if (arguments.length <= 0 || arguments[0] == null) {
return format;
}
MESSAGE_ERROR_SAMPLE;
- /**
+ /*
* Static initializer to ensure the resource bundles for this class are loaded... Here this
* application loads messages from three bundles.
*/
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
debugLogger.info(MessageCodes.GENERAL_INFO, message + arguments2);
return;
}
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
debugLogger.warn(MessageCodes.GENERAL_INFO, message + arguments2);
return;
}
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
errorLogger.error(MessageCodes.GENERAL_ERROR, message + arguments2);
return;
}
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
debugLogger.debug(MessageCodes.GENERAL_INFO, message + arguments2);
return;
}
return;
}
if (arguments.length == 1 && OnapLoggingUtils.isThrowable(arguments[0])) {
- String arguments2 = getNormalizedStackTrace((Throwable)arguments[0], "");
+ String arguments2 = getNormalizedStackTrace((Throwable) arguments[0], "");
metricsLogger.info(MessageCodes.RULE_METRICS_INFO, message + arguments2);
return;
}
if (ParameterGroup.class.isAssignableFrom(fieldType)) {
if (null != fieldObject) {
return ((ParameterGroup) fieldObject).validate();
- }
- else {
+ } else {
return new GroupValidationResult((ParameterGroup) fieldObject);
}
}
@Test
public void testValidateMap() {
- Map<String,ValidationResult> map = null;
+ Map<String, ValidationResult> map = null;
bean = new BeanValidationResult(NAME, OBJECT);
assertTrue(bean.validateMap(MY_MAP, map, validMapEntry()));
assertTrue(bean.isValid());
public void triggerValidationStatus(final ValidationStatus triggerStatus, int level) {
if (level == 0) {
return;
- }
- else {
+ } else {
level--;
}
assertEquals("[list, null, 21]", list.toString());
// map
- Map<String,Object> map = new LinkedHashMap<>();
+ Map<String, Object> map = new LinkedHashMap<>();
map.put("map-A", "map-value");
map.put("map-B", null);
map.put("map-C", 22.0);
@Test
public void testConvertFromDoubleMap() {
// null is ok
- DoubleConverter.convertFromDouble((Map<String,Object>) null);
+ DoubleConverter.convertFromDouble((Map<String, Object>) null);
- Map<String,Object> map = new LinkedHashMap<>();
+ Map<String, Object> map = new LinkedHashMap<>();
map.put("keyA", "valueA");
map.put("keyB", 200.0);
- Map<String,Object> nested = new LinkedHashMap<>();
+ Map<String, Object> nested = new LinkedHashMap<>();
map.put("keyC", nested);
nested.put("nested-key", 201.0);
*/
public IntegrityAuditEntity getMyIntegrityAuditEntity() throws DbDaoTransactionException {
- return updateIae("getMyIntegrityAuditEntity", this.resourceName, this.persistenceUnit, (em,iae) -> {
+ return updateIae("getMyIntegrityAuditEntity", this.resourceName, this.persistenceUnit, (em, iae) -> {
if (iae != null) {
// refresh the object from DB in case cached data was returned
*/
private void register(String altDbUrl) throws DbDaoTransactionException {
- updateIae("register", this.resourceName, this.persistenceUnit, (em,iae) -> {
+ updateIae("register", this.resourceName, this.persistenceUnit, (em, iae) -> {
IntegrityAuditEntity iae2 = iae;
// If it already exists, we just want to update the properties and lastUpdated date
logger.debug("setDesignated: enter, resourceName: " + resourceName + ", persistenceUnit: " + persistenceUnit
+ ", designated: " + desig);
- updateIae("setDesignated", resourceName, persistenceUnit, (em,iae) -> {
+ updateIae("setDesignated", resourceName, persistenceUnit, (em, iae) -> {
if (iae != null) {
// refresh the object from DB in case cached data was returned
* @throws DbDaoTransactionException if an error occurs
*/
private IntegrityAuditEntity updateIae(String methodName, String resourceName, String persistenceUnit,
- BiConsumer<EntityManager,IntegrityAuditEntity> updater) throws DbDaoTransactionException {
+ BiConsumer<EntityManager, IntegrityAuditEntity> updater) throws DbDaoTransactionException {
try {
EntityManager em = emf.createEntityManager();
logger.debug("setLastUpdated: enter, resourceName: " + this.resourceName + ", persistenceUnit: "
+ this.persistenceUnit);
- updateIae("setLastUpdated", this.resourceName, this.persistenceUnit, (em,iae) -> {
+ updateIae("setLastUpdated", this.resourceName, this.persistenceUnit, (em, iae) -> {
if (iae != null) {
// refresh the object from DB in case cached data was returned
// create instance of StateManagement class and pass emf to it
stateManager = new StateManagement(emf, resourceName);
- /**
+ /*
* Initialize the state and status attributes. This will maintain any Administrative state value but will
* set the operational state = enabled, availability status = null, standby status = null. The integrity
* monitor will set the operational state via the FPManager and the owning application must set the standby
* was updated, {@code null} if no change was made
* @throws StateManagementException if an error occurs
*/
- private void setState(String methodName, String resourceName, ExFunction<StateManagementEntity,String> updateState)
+ private void setState(String methodName, String resourceName, ExFunction<StateManagementEntity, String> updateState)
throws StateManagementException {
synchronized (SYNCLOCK) {
}
@FunctionalInterface
- private static interface ExFunction<T,R> {
+ private static interface ExFunction<T, R> {
public R update(T object) throws IntegrityMonitorException;
}
*/
public DmaapDmePublisherWrapper(BusTopicParams busTopicParams) {
- super(ProtocolTypeConstants.DME2, busTopicParams.getServers(),busTopicParams.getTopic(),
- busTopicParams.getUserName(),busTopicParams.getPassword(),busTopicParams.isUseHttps());
+ super(ProtocolTypeConstants.DME2, busTopicParams.getServers(), busTopicParams.getTopic(),
+ busTopicParams.getUserName(), busTopicParams.getPassword(), busTopicParams.isUseHttps());
String dme2RouteOffer = busTopicParams.isAdditionalPropsValid()
? busTopicParams.getAdditionalProps().get(
/**
* Maps a topic property to a DME property.
*/
- private static final Map<String,String> PROP_TO_DME;
+ private static final Map<String, String> PROP_TO_DME;
static {
- Map<String,String> map = new HashMap<>();
+ Map<String, String> map = new HashMap<>();
map.put(PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ROUTE_OFFER_SUFFIX,
PolicyEndPointProperties.DME2_ROUTE_OFFER_PROPERTY);
}
@FunctionalInterface
- public static interface TriConsumer<A,B,C> {
+ public static interface TriConsumer<A, B, C> {
public void accept(A propName, B propValue, C exception);
}
}
logger.info("-- testMultipleServers() --");
HttpServletServer server1 = HttpServletServerFactoryInstance.getServerFactory()
- .build("echo-1", false,LOCALHOST, port, "/", true, true);
+ .build("echo-1", false, LOCALHOST, port, "/", true, true);
server1.addServletPackage("/*", this.getClass().getPackage().getName());
server1.waitedStart(5000);
ONAP policy
================================================================================
Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019-2020 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
</dependency>
</dependencies>
</plugin>
- <plugin>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <executions>
- <execution>
- <id>onap-java-style</id>
- <goals>
- <goal>check</goal>
- </goals>
- <phase>process-sources</phase>
- <configuration>
- <!-- Use Google Java Style Guide:
- https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
- with minor changes -->
- <configLocation>onap-checkstyle/onap-java-style.xml</configLocation>
- <!-- <sourceDirectory> is needed so that checkstyle ignores the generated sources directory -->
- <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
- <includeResources>true</includeResources>
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
- <includeTestResources>true</includeTestResources>
- <excludes>
- </excludes>
- <consoleOutput>true</consoleOutput>
- <failsOnViolation>true</failsOnViolation>
- <violationSeverity>warning</violationSeverity>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.onap.oparent</groupId>
- <artifactId>checkstyle</artifactId>
- <version>${oparent.version}</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- </plugin>
</plugins>
</build>
<reporting>
if (charsRead > 0) {
builder.append(chars, 0, charsRead);
}
- }
- while (charsRead > 0);
+ } while (charsRead > 0);
return builder.toString();
}
}
* otherwise
*/
public static <T> boolean apply(List<T> providers, Predicate<T> predicate,
- BiConsumer<T,Exception> handleEx) {
+ BiConsumer<T, Exception> handleEx) {
for (T feature : providers) {
try {
private ServiceLoader<T> serviceLoader = null;
// use this to ensure that we only use one unique instance of each class
- private static Map<Class<?>,OrderedService> classToSingleton = new HashMap<>();
+ private static Map<Class<?>, OrderedService> classToSingleton = new HashMap<>();
/**
* Constructor - create the 'ServiceLoader' instance.
// build a list of all of the current implementors
List<T> tmp = new LinkedList<>();
for (T service : serviceLoader) {
- tmp.add((T)getSingleton(service));
+ tmp.add((T) getSingleton(service));
}
// Sort the list according to sequence number, and then alphabetically
this.major = newVersion.major;
this.minor = newVersion.minor;
this.patch = newVersion.patch;
- }
- else {
+ } else {
this.major = 0;
this.minor = 0;
this.patch = 0;
Map<String, Object> result = PropertyObjectUtils.toObject(props, "");
// @formatter:off
- Map<String,Object> map =
+ Map<String, Object> map =
Map.of("abc",
Arrays.asList(null, "expand.ghi", "expand.def"));
// @formatter:on
Map<String, Object> result = PropertyObjectUtils.toObject(props, "");
// @formatter:off
- Map<String,Object> map =
+ Map<String, Object> map =
Map.of("object",
Map.of("abc",
Map.of("ghi", "object.jkl")));
Map<String, Object> result = PropertyObjectUtils.toObject(props, "");
// @formatter:off
- Map<String,Object> map =
+ Map<String, Object> map =
Map.of("array",
Map.of("abc",
List.of(
*/
@Test
public void testPropertyAccessExceptionStringField() {
- verifyPropertyExceptionStringField_AllPopulated( new PropertyAccessException(PROPERTY, FIELD));
- verifyPropertyExceptionStringField_NullProperty( new PropertyAccessException(null, FIELD));
- verifyPropertyExceptionStringField_NullField( new PropertyAccessException(PROPERTY, null));
- verifyPropertyExceptionStringField_BothNull( new PropertyAccessException(null, null));
+ verifyPropertyExceptionStringField_AllPopulated(new PropertyAccessException(PROPERTY, FIELD));
+ verifyPropertyExceptionStringField_NullProperty(new PropertyAccessException(null, FIELD));
+ verifyPropertyExceptionStringField_NullField(new PropertyAccessException(PROPERTY, null));
+ verifyPropertyExceptionStringField_BothNull(new PropertyAccessException(null, null));
}
/**
public void testApplyFeatureFalse() {
List<String> lst = Arrays.asList("falseF1", "exceptF2", "falseF3");
- assertFalse(FeatureApiUtils.apply(lst, pred, (str,ex) -> errors.add(str)));
+ assertFalse(FeatureApiUtils.apply(lst, pred, (str, ex) -> errors.add(str)));
assertEquals(lst.toString(), tried.toString());
assertEquals("[exceptF2]", errors.toString());
}