private static final int SCHEDULING_DELAY_FOR_DATAFILE_COLLECTOR_TASKS = 10;
private static final int SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY = 5;
- private static volatile List<ScheduledFuture> scheduledFutureList = new ArrayList<ScheduledFuture>();
+ private static volatile List<ScheduledFuture> scheduledFutureList = new ArrayList<>();
private final TaskScheduler taskScheduler;
private final ScheduledTasks scheduledTask;
private boolean isNotificationFieldsHeaderNotEmpty(String changeIdentifier, String changeType,
String notificationFieldsVersion) {
- return ((changeIdentifier != null && !changeIdentifier.isEmpty())
- && (changeType != null && !changeType.isEmpty())
- && (notificationFieldsVersion != null && !notificationFieldsVersion.isEmpty()));
+ return isStringIsNotNullAndNotEmpty(changeIdentifier) && isStringIsNotNullAndNotEmpty(changeType)
+ && isStringIsNotNullAndNotEmpty(notificationFieldsVersion);
}
private boolean isFileFormatFieldsNotEmpty(String fileFormatVersion, String fileFormatType) {
- return ((fileFormatVersion != null && !fileFormatVersion.isEmpty())
- && (fileFormatType != null && !fileFormatType.isEmpty()));
+ return isStringIsNotNullAndNotEmpty(fileFormatVersion) && isStringIsNotNullAndNotEmpty(fileFormatType);
}
private boolean isNameAndLocationAndCompressionNotEmpty(String name, String location, String compression) {
- return (name != null && !name.isEmpty()) && (location != null && !location.isEmpty())
- && (compression != null && !compression.isEmpty());
+ return isStringIsNotNullAndNotEmpty(name) && isStringIsNotNullAndNotEmpty(location) &&
+ isStringIsNotNullAndNotEmpty(compression);
}
private boolean containsHeader(JsonObject jsonObject) {
private boolean containsHeader(JsonObject jsonObject, String topHeader, String header) {
return jsonObject.has(topHeader) && jsonObject.getAsJsonObject(topHeader).has(header);
}
+
+ private boolean isStringIsNotNullAndNotEmpty(String string) {
+ return string != null && !string.isEmpty();
+ }
}
class CloudConfigParserTest {
- private static final String correctJson =
+ private static final String CORRECT_JSON =
"{\"dmaap.dmaapProducerConfiguration.dmaapTopicName\": \"/events/unauthenticated.VES_NOTIFICATION_OUTPUT\", "
+ "\"dmaap.dmaapConsumerConfiguration.timeoutMS\": -1,"
+ " \"dmaap.dmaapConsumerConfiguration.dmaapHostName\": \"message-router.onap.svc.cluster.local\","
.build();
private CloudConfigParser cloudConfigParser = new CloudConfigParser(
- new Gson().fromJson(correctJson, JsonObject.class));
+ new Gson().fromJson(CORRECT_JSON, JsonObject.class));
@Test
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
public class CommonFunctions {
- private static final Logger logger = LoggerFactory.getLogger(CommonFunctions.class);
-
private static Gson gson = new GsonBuilder().create();
-
private CommonFunctions() {}
public static String createJsonBody(ConsumerDmaapModel consumerDmaapModel) {