mirror of https://github.com/apache/nifi.git
NIFI-13238 Added Checkstyle rules for whitespace
This closes #8832 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
63a12b06b5
commit
ee179f4acf
|
@ -39,7 +39,7 @@ public class C2OperationHandlerProviderTest {
|
|||
private static C2OperationAck operationAck;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup(){
|
||||
public static void setup() {
|
||||
operationAck = new C2OperationAck();
|
||||
operationAck.setOperationId("12345");
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class MultiProcessorUseCase implements Serializable {
|
|||
private List<String> keywords;
|
||||
private List<ProcessorConfiguration> configurations;
|
||||
|
||||
@Schema(description="A description of the use case")
|
||||
@Schema(description = "A description of the use case")
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class MultiProcessorUseCase implements Serializable {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
@Schema(description="Any pertinent notes about the use case")
|
||||
@Schema(description = "Any pertinent notes about the use case")
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class MultiProcessorUseCase implements Serializable {
|
|||
this.notes = notes;
|
||||
}
|
||||
|
||||
@Schema(description="Keywords that pertain to the use csae")
|
||||
@Schema(description = "Keywords that pertain to the use csae")
|
||||
public List<String> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class MultiProcessorUseCase implements Serializable {
|
|||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
@Schema(description="A description of how to configure the Processor to perform the task described in the use case")
|
||||
@Schema(description = "A description of how to configure the Processor to perform the task described in the use case")
|
||||
public List<ProcessorConfiguration> getConfigurations() {
|
||||
return configurations;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ProcessorConfiguration implements Serializable {
|
|||
private String processorClassName;
|
||||
private String configuration;
|
||||
|
||||
@Schema(description="The fully qualified classname of the Processor that should be used to accomplish the use case")
|
||||
@Schema(description = "The fully qualified classname of the Processor that should be used to accomplish the use case")
|
||||
public String getProcessorClassName() {
|
||||
return processorClassName;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class ProcessorConfiguration implements Serializable {
|
|||
this.processorClassName = processorClassName;
|
||||
}
|
||||
|
||||
@Schema(description="A description of how the Processor should be configured in order to accomplish the use case")
|
||||
@Schema(description = "A description of how the Processor should be configured in order to accomplish the use case")
|
||||
public String getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ProcessorDefinition extends ConfigurableExtensionDefinition {
|
|||
private List<MultiProcessorUseCase> multiProcessorUseCases;
|
||||
|
||||
|
||||
@Schema(description="Any input requirements this processor has.")
|
||||
@Schema(description = "Any input requirements this processor has.")
|
||||
public InputRequirement.Requirement getInputRequirement() {
|
||||
return inputRequirement;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ public class ProcessorDefinition extends ConfigurableExtensionDefinition {
|
|||
this.writesAttributes = writesAttributes;
|
||||
}
|
||||
|
||||
@Schema(description="A list of use cases that have been documented for this Processor")
|
||||
@Schema(description = "A list of use cases that have been documented for this Processor")
|
||||
public List<UseCase> getUseCases() {
|
||||
return useCases;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ public class ProcessorDefinition extends ConfigurableExtensionDefinition {
|
|||
this.useCases = useCases;
|
||||
}
|
||||
|
||||
@Schema(description="A list of use cases that have been documented that involve this Processor in conjunction with other Processors")
|
||||
@Schema(description = "A list of use cases that have been documented that involve this Processor in conjunction with other Processors")
|
||||
public List<MultiProcessorUseCase> getMultiProcessorUseCases() {
|
||||
return multiProcessorUseCases;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class UseCase implements Serializable {
|
|||
private String configuration;
|
||||
private InputRequirement.Requirement inputRequirement;
|
||||
|
||||
@Schema(description="A description of the use case")
|
||||
@Schema(description = "A description of the use case")
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class UseCase implements Serializable {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
@Schema(description="Any pertinent notes about the use case")
|
||||
@Schema(description = "Any pertinent notes about the use case")
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class UseCase implements Serializable {
|
|||
this.notes = notes;
|
||||
}
|
||||
|
||||
@Schema(description="Keywords that pertain to the use case")
|
||||
@Schema(description = "Keywords that pertain to the use case")
|
||||
public List<String> getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class UseCase implements Serializable {
|
|||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
@Schema(description="A description of how to configure the Processor to perform the task described in the use case")
|
||||
@Schema(description = "A description of how to configure the Processor to perform the task described in the use case")
|
||||
public String getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class UseCase implements Serializable {
|
|||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@Schema(description="Specifies whether an incoming FlowFile is expected for this use case")
|
||||
@Schema(description = "Specifies whether an incoming FlowFile is expected for this use case")
|
||||
public InputRequirement.Requirement getInputRequirement() {
|
||||
return inputRequirement;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,10 @@
|
|||
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
</module>
|
||||
<module name="TreeWalker">
|
||||
<module name="WhitespaceAfter"/>
|
||||
<module name="NoWhitespaceAfter"/>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="WhitespaceAround"/>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="\s+$"/>
|
||||
<property name="message" value="Line has trailing whitespace."/>
|
||||
|
|
|
@ -38,7 +38,7 @@ public class FlowStatusRunner implements CommandRunner {
|
|||
*/
|
||||
@Override
|
||||
public int runCommand(String[] args) {
|
||||
if(args.length == 2) {
|
||||
if (args.length == 2) {
|
||||
CMD_LOGGER.info(periodicStatusReporterManager.statusReport(args[1]).toString());
|
||||
return OK.getStatusCode();
|
||||
} else {
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class PeriodicStatusReporter {
|
|||
* 'reportRunner' prior to this method being called.
|
||||
*/
|
||||
public void start() {
|
||||
if (reportRunner == null){
|
||||
if (reportRunner == null) {
|
||||
throw new IllegalStateException("Programmatic error, the reportRunner is still NULL when 'start' was called.");
|
||||
}
|
||||
scheduledExecutorService.scheduleAtFixedRate(reportRunner, period, period, TimeUnit.MILLISECONDS);
|
||||
|
|
|
@ -68,7 +68,7 @@ public class OrderedProperties extends Properties {
|
|||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
super.store(byteArrayOutputStream, comments);
|
||||
|
||||
try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), "8859_1"));
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), "8859_1"));
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
|
|
|
@ -46,7 +46,7 @@ public class OrderedPropertiesTest {
|
|||
try (BufferedReader actualReader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())));
|
||||
BufferedReader expectedReader = new BufferedReader(new InputStreamReader(OrderedPropertiesTest.class.getClassLoader().getResourceAsStream("orderedPropertiesExpected.properties")))) {
|
||||
String expectedLine;
|
||||
while((expectedLine = expectedReader.readLine()) != null) {
|
||||
while ((expectedLine = expectedReader.readLine()) != null) {
|
||||
String actualLine = actualReader.readLine();
|
||||
if (!"#Tue Feb 21 11:03:08 EST 2017".equals(expectedLine)) {
|
||||
assertEquals(expectedLine, actualLine);
|
||||
|
|
|
@ -145,7 +145,7 @@ public class FlowStatusReport implements java.io.Serializable {
|
|||
public String toString() {
|
||||
|
||||
StringWriter jsonString = new StringWriter();
|
||||
try(JsonGenerator generator = objectMapper.getFactory().createGenerator(jsonString)){
|
||||
try (JsonGenerator generator = objectMapper.getFactory().createGenerator(jsonString)) {
|
||||
generator.writeStartObject();
|
||||
generator.writeObjectField("controllerServiceStatusList", controllerServiceStatusList);
|
||||
generator.writeObjectField("processorStatusList", processorStatusList);
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ProcessorStatusBean extends AbstractStatusBean {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "{" +
|
||||
"id='" + getId()+ '\'' +
|
||||
"id='" + getId() + '\'' +
|
||||
"name='" + getName() + '\'' +
|
||||
", processorHealth=" + processorHealth +
|
||||
", processorStats=" + processorStats +
|
||||
|
|
|
@ -43,7 +43,10 @@ public class LogUtil {
|
|||
List<ExpectedLogEntry> expectedLogEntries;
|
||||
try (InputStream inputStream = LogUtil.class.getClassLoader().getResourceAsStream(expectedJsonFilename)) {
|
||||
List<Map<String, Object>> expected = new ObjectMapper().readValue(inputStream, List.class);
|
||||
expectedLogEntries = expected.stream().map(map -> new ExpectedLogEntry(Pattern.compile((String)map.get("pattern")), (int) map.getOrDefault("occurrences", 1))).collect(Collectors.toList());
|
||||
expectedLogEntries = expected
|
||||
.stream()
|
||||
.map(map -> new ExpectedLogEntry(Pattern.compile((String) map.get("pattern")), (int) map.getOrDefault("occurrences", 1)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
DockerPort dockerPort = container.port(8000);
|
||||
logger.info("Connecting to external port {} for docker internal port of {}", new Object[]{dockerPort.getExternalPort(), dockerPort.getInternalPort()});
|
||||
|
|
|
@ -132,7 +132,7 @@ class PropertiesPersisterTest {
|
|||
}
|
||||
|
||||
private void writeBootstrapFile(String property) {
|
||||
try(BufferedWriter writer = new BufferedWriter(new FileWriter(bootstrapConfigFileLocation))) {
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(bootstrapConfigFileLocation))) {
|
||||
writer.write(property + System.lineSeparator());
|
||||
writer.write(EXTRA_PROPERTY_KEY + "=" + EXTRA_PROPERTY_VALUE);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -38,7 +38,7 @@ class BootstrapConfigurationFileTransformerTest {
|
|||
private static final String BOOTSTRAP_ROOT_KEY_PROPERTY = "minifi.bootstrap.sensitive.key";
|
||||
private static final String MOCK_KEY = "mockKey";
|
||||
private static final String BOOTSTRAP_CONF_FILE_WITHOUT_KEY = "/transformer/bootstrap_without_key.conf";
|
||||
private static final String BOOTSTRAP_CONF_TRANSFORMED= "transformed.conf";
|
||||
private static final String BOOTSTRAP_CONF_TRANSFORMED = "transformed.conf";
|
||||
|
||||
@TempDir
|
||||
private Path tempDir;
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ControllerServiceSchema extends BaseSchemaWithIdAndName {
|
|||
result.put(TYPE_KEY, serviceClass);
|
||||
result.put(PROPERTIES_KEY, new TreeMap<>(properties));
|
||||
|
||||
if(annotationData != null && !annotationData.isEmpty()) {
|
||||
if (annotationData != null && !annotationData.isEmpty()) {
|
||||
result.put(ANNOTATION_DATA_KEY, annotationData);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public class ProcessorSchema extends BaseSchemaWithIdAndName {
|
|||
result.put(AUTO_TERMINATED_RELATIONSHIPS_LIST_KEY, autoTerminatedRelationshipsList);
|
||||
result.put(PROPERTIES_KEY, new TreeMap<>(properties));
|
||||
|
||||
if(annotationData != null && !annotationData.isEmpty()) {
|
||||
if (annotationData != null && !annotationData.isEmpty()) {
|
||||
result.put(ANNOTATION_DATA_KEY, annotationData);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,7 @@ public class ProvenanceRepositorySchema extends BaseSchema implements WritableSc
|
|||
private String provenanceRepoMaxStorageTime = DEFAULT_PROVENANCE_REPO_MAX_STORAGE_TIME;
|
||||
private Integer provenanceRepoBufferSize = DEFAULT_PROVENANCE_REPO_BUFFER_SIZE;
|
||||
|
||||
public ProvenanceRepositorySchema(){
|
||||
}
|
||||
public ProvenanceRepositorySchema() { }
|
||||
|
||||
public ProvenanceRepositorySchema(Map map) {
|
||||
provenanceRepoRolloverTime = getOptionalKeyAsType(map, PROVENANCE_REPO_ROLLOVER_TIME_KEY, String.class,
|
||||
|
|
|
@ -56,7 +56,7 @@ public class RemoteProcessGroupSchema extends BaseSchemaWithIdAndName {
|
|||
public static final String DEFAULT_COMMENT = "";
|
||||
public static final String DEFAULT_TIMEOUT = "30 secs";
|
||||
public static final String DEFAULT_YIELD_PERIOD = "10 sec";
|
||||
public static final String DEFAULT_TRANSPORT_PROTOCOL= "RAW";
|
||||
public static final String DEFAULT_TRANSPORT_PROTOCOL = "RAW";
|
||||
public static final String DEFAULT_PROXY_HOST = "";
|
||||
public static final Integer DEFAULT_PROXY_PORT = null;
|
||||
public static final String DEFAULT_PROXY_USER = "";
|
||||
|
@ -99,7 +99,7 @@ public class RemoteProcessGroupSchema extends BaseSchemaWithIdAndName {
|
|||
yieldPeriod = getOptionalKeyAsType(map, YIELD_PERIOD_KEY, String.class, wrapperName, DEFAULT_YIELD_PERIOD);
|
||||
transportProtocol = getOptionalKeyAsType(map, TRANSPORT_PROTOCOL_KEY, String.class, wrapperName, DEFAULT_TRANSPORT_PROTOCOL);
|
||||
|
||||
if (!TransportProtocolOptions.valid(transportProtocol)){
|
||||
if (!TransportProtocolOptions.valid(transportProtocol)) {
|
||||
addValidationIssue(TRANSPORT_PROTOCOL_KEY, wrapperName, "it must be either 'RAW' or 'HTTP' but is '" + transportProtocol + "'");
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ public abstract class BaseSchema implements Schema {
|
|||
return validationIssues.stream().sorted().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addValidationIssue(String issue) {
|
||||
validationIssues.add(issue);
|
||||
}
|
||||
|
@ -96,7 +97,7 @@ public abstract class BaseSchema implements Schema {
|
|||
if (value == null || (targetClass != String.class && "".equals(value))) {
|
||||
if (defaultValue != null) {
|
||||
return defaultValue;
|
||||
} else if(required) {
|
||||
} else if (required) {
|
||||
addValidationIssue(key, wrapperName, IT_WAS_NOT_FOUND_AND_IT_IS_REQUIRED);
|
||||
}
|
||||
} else {
|
||||
|
@ -120,7 +121,7 @@ public abstract class BaseSchema implements Schema {
|
|||
return interpretValueAsType(obj, key, targetClass, wrapperName, required, instantiateIfNull);
|
||||
}
|
||||
|
||||
public <InputT, OutputT> List<OutputT> convertListToType(List<InputT> list, String simpleListType, Class<? extends OutputT> targetClass, String wrapperName){
|
||||
public <InputT, OutputT> List<OutputT> convertListToType(List<InputT> list, String simpleListType, Class<? extends OutputT> targetClass, String wrapperName) {
|
||||
if (list == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
@ -170,10 +171,10 @@ public abstract class BaseSchema implements Schema {
|
|||
|
||||
private <T> T interpretValueAsType(Object obj, String key, Class targetClass, String wrapperName, boolean required, boolean instantiateIfNull) {
|
||||
if (obj == null || (targetClass != String.class && "".equals(obj))) {
|
||||
if (required){
|
||||
if (required) {
|
||||
addValidationIssue(key, wrapperName, "it is a required property but was not found");
|
||||
} else {
|
||||
if(instantiateIfNull) {
|
||||
if (instantiateIfNull) {
|
||||
try {
|
||||
return (T) targetClass.getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
||||
|
|
|
@ -214,7 +214,7 @@ public class ConfigSchemaV1 extends BaseSchema implements ConvertableSchema<Conf
|
|||
|
||||
protected List<RemoteProcessGroupSchema> getRemoteProcessGroupSchemas() {
|
||||
Set<UUID> ids = new HashSet<>();
|
||||
List<RemoteProcessGroupSchema> rpgSchemas= new ArrayList<>(remoteProcessingGroups.size());
|
||||
List<RemoteProcessGroupSchema> rpgSchemas = new ArrayList<>(remoteProcessingGroups.size());
|
||||
|
||||
for (RemoteProcessGroupSchemaV1 rpg : remoteProcessingGroups) {
|
||||
RemoteProcessGroupSchema rpgSchema = rpg.convert();
|
||||
|
|
|
@ -66,7 +66,7 @@ public class RemoteProcessGroupSchemaV2 extends BaseSchema implements Convertabl
|
|||
yieldPeriod = getOptionalKeyAsType(map, YIELD_PERIOD_KEY, String.class, wrapperName, DEFAULT_YIELD_PERIOD);
|
||||
transportProtocol = getOptionalKeyAsType(map, TRANSPORT_PROTOCOL_KEY, String.class, wrapperName, DEFAULT_TRANSPORT_PROTOCOL);
|
||||
|
||||
if (!TransportProtocolOptions.valid(transportProtocol)){
|
||||
if (!TransportProtocolOptions.valid(transportProtocol)) {
|
||||
addValidationIssue(TRANSPORT_PROTOCOL_KEY, wrapperName, "it must be either 'RAW' or 'HTTP' but is '" + transportProtocol + "'");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class RemoteProcessGroupSchemaTest {
|
|||
|
||||
map.put(RemoteProcessGroupSchema.TRANSPORT_PROTOCOL_KEY, "RAW");
|
||||
RemoteProcessGroupSchema first = new RemoteProcessGroupSchema(map);
|
||||
validateIssuesNumMatches(0,first);
|
||||
validateIssuesNumMatches(0, first);
|
||||
assertEquals(first.getTransportProtocol(), "RAW");
|
||||
|
||||
map.put(RemoteProcessGroupSchema.TRANSPORT_PROTOCOL_KEY, "HTTP");
|
||||
|
@ -81,7 +81,7 @@ public class RemoteProcessGroupSchemaTest {
|
|||
|
||||
map.put(RemoteProcessGroupSchema.LOCAL_NETWORK_INTERFACE_KEY, "eth1");
|
||||
RemoteProcessGroupSchema first = new RemoteProcessGroupSchema(map);
|
||||
validateIssuesNumMatches(0,first);
|
||||
validateIssuesNumMatches(0, first);
|
||||
assertEquals(first.getLocalNetworkInterface(), "eth1");
|
||||
}
|
||||
@Test
|
||||
|
|
|
@ -58,7 +58,7 @@ public class RemoteProcessGroupSchemaV2Test {
|
|||
|
||||
map.put(RemoteProcessGroupSchema.TRANSPORT_PROTOCOL_KEY, "RAW");
|
||||
RemoteProcessGroupSchemaV2 first = new RemoteProcessGroupSchemaV2(map);
|
||||
validateIssuesNumMatches(0,first);
|
||||
validateIssuesNumMatches(0, first);
|
||||
assertEquals(first.getTransportProtocol(), "RAW");
|
||||
|
||||
map.put(RemoteProcessGroupSchema.TRANSPORT_PROTOCOL_KEY, "HTTP");
|
||||
|
|
|
@ -35,6 +35,6 @@ public interface PropertyContext {
|
|||
PropertyValue getProperty(PropertyDescriptor descriptor);
|
||||
|
||||
|
||||
Map<String,String> getAllProperties();
|
||||
Map<String, String> getAllProperties();
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class QueryWindow {
|
|||
return new Date(endTimeMillis);
|
||||
}
|
||||
|
||||
public long getTimeDifferenceMillis(){
|
||||
public long getTimeDifferenceMillis() {
|
||||
return endTimeMillis - startTimeMillis;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public interface StatusAnalytics {
|
|||
* is the value for the prediction
|
||||
* @return map
|
||||
*/
|
||||
Map<String,Long> getPredictions();
|
||||
Map<String, Long> getPredictions();
|
||||
|
||||
/**
|
||||
* Return if analytics object supports online learning
|
||||
|
|
|
@ -42,7 +42,7 @@ public interface StatusAnalyticsModel {
|
|||
* @param label known target value
|
||||
* @return prediction for variable
|
||||
*/
|
||||
Double predictVariable(Integer predictVariableIndex, Map<Integer,Double> knownVariablesWithIndex, Double label);
|
||||
Double predictVariable(Integer predictVariableIndex, Map<Integer, Double> knownVariablesWithIndex, Double label);
|
||||
|
||||
/**
|
||||
* Indicate if model supports online learning (e.g. can learn new observation samples to create a model)
|
||||
|
@ -54,7 +54,7 @@ public interface StatusAnalyticsModel {
|
|||
* Returns a map of scores relevant to model (e.g. rSquared, Confidence Intervals, etc.)
|
||||
* @return Map of score names with values
|
||||
*/
|
||||
Map<String,Double> getScores();
|
||||
Map<String, Double> getScores();
|
||||
|
||||
/**
|
||||
* Resets a model by clearing observations and other calculations
|
||||
|
|
|
@ -56,7 +56,7 @@ public class StorageUsage implements Cloneable {
|
|||
}
|
||||
|
||||
public int getDiskUtilization() {
|
||||
return Math.round(((float)getUsedSpace() / totalSpace) * 100);
|
||||
return Math.round(((float) getUsedSpace() / totalSpace) * 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -127,7 +127,7 @@ public abstract class AbstractDocumentationWriter implements ExtensionDocumentat
|
|||
}
|
||||
|
||||
@Override
|
||||
public final void write(final ConfigurableComponent component, final Collection<ServiceAPI> providedServices, Map<String,ServiceAPI> propertyServices) throws IOException {
|
||||
public final void write(final ConfigurableComponent component, final Collection<ServiceAPI> providedServices, Map<String, ServiceAPI> propertyServices) throws IOException {
|
||||
writeHeader(component);
|
||||
writeBody(component, propertyServices);
|
||||
|
||||
|
@ -138,7 +138,7 @@ public abstract class AbstractDocumentationWriter implements ExtensionDocumentat
|
|||
writeFooter(component);
|
||||
}
|
||||
|
||||
protected void writeBody(final ConfigurableComponent component, Map<String,ServiceAPI> propertyServices) throws IOException {
|
||||
protected void writeBody(final ConfigurableComponent component, Map<String, ServiceAPI> propertyServices) throws IOException {
|
||||
writeExtensionName(component.getClass().getName());
|
||||
writeExtensionType(getExtensionType(component));
|
||||
writeDeprecationNotice(component.getClass().getAnnotation(DeprecationNotice.class));
|
||||
|
@ -313,7 +313,7 @@ public abstract class AbstractDocumentationWriter implements ExtensionDocumentat
|
|||
|
||||
protected abstract void writeTags(List<String> tags) throws IOException;
|
||||
|
||||
protected abstract void writeProperties(List<PropertyDescriptor> properties, Map<String,ServiceAPI> propertyServices) throws IOException;
|
||||
protected abstract void writeProperties(List<PropertyDescriptor> properties, Map<String, ServiceAPI> propertyServices) throws IOException;
|
||||
|
||||
protected abstract void writeDynamicProperties(List<DynamicProperty> dynamicProperties) throws IOException;
|
||||
|
||||
|
|
|
@ -58,6 +58,6 @@ public interface ExtensionDocumentationWriter {
|
|||
* @param propertyServiceAPIs the service APIs required by the property descriptors of the component
|
||||
* @throws IOException if an error occurs writing the documentation
|
||||
*/
|
||||
void write(ConfigurableComponent component, Collection<ServiceAPI> provideServices, Map<String,ServiceAPI> propertyServiceAPIs) throws IOException;
|
||||
void write(ConfigurableComponent component, Collection<ServiceAPI> provideServices, Map<String, ServiceAPI> propertyServiceAPIs) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public class XmlDocumentationWriter extends AbstractDocumentationWriter {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void writeProperties(final List<PropertyDescriptor> properties, Map<String,ServiceAPI> propertyServices) throws IOException {
|
||||
protected void writeProperties(final List<PropertyDescriptor> properties, Map<String, ServiceAPI> propertyServices) throws IOException {
|
||||
if (properties == null || properties.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class XmlDocumentationWriter extends AbstractDocumentationWriter {
|
|||
writeEndElement();
|
||||
}
|
||||
|
||||
private void writeProperty(final PropertyDescriptor property, Map<String,ServiceAPI> propertyServices) throws IOException {
|
||||
private void writeProperty(final PropertyDescriptor property, Map<String, ServiceAPI> propertyServices) throws IOException {
|
||||
writeStartElement("property");
|
||||
|
||||
writeTextElement("name", property.getName());
|
||||
|
@ -434,7 +434,7 @@ public class XmlDocumentationWriter extends AbstractDocumentationWriter {
|
|||
return;
|
||||
}
|
||||
|
||||
writeArray("relationships", relationships,rel -> {
|
||||
writeArray("relationships", relationships, rel -> {
|
||||
writeStartElement("relationship");
|
||||
|
||||
writeTextElement("name", rel.getName());
|
||||
|
@ -585,10 +585,10 @@ public class XmlDocumentationWriter extends AbstractDocumentationWriter {
|
|||
private void writeProvidedService(final ServiceAPI service) throws IOException {
|
||||
writeStartElement("providedServiceAPI");
|
||||
|
||||
writeTextElement("className",service.getClassName());
|
||||
writeTextElement("groupId",service.getGroupId());
|
||||
writeTextElement("artifactId",service.getArtifactId());
|
||||
writeTextElement("version",service.getVersion());
|
||||
writeTextElement("className", service.getClassName());
|
||||
writeTextElement("groupId", service.getGroupId());
|
||||
writeTextElement("artifactId", service.getArtifactId());
|
||||
writeTextElement("version", service.getVersion());
|
||||
|
||||
writeEndElement();
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ public interface VersionedConfigurableComponent {
|
|||
|
||||
void setPropertyDescriptors(Map<String, VersionedPropertyDescriptor> propertyDescriptors);
|
||||
|
||||
Map<String,String> getProperties();
|
||||
Map<String, String> getProperties();
|
||||
|
||||
void setProperties(Map<String,String> properties);
|
||||
void setProperties(Map<String, String> properties);
|
||||
|
||||
}
|
||||
|
|
|
@ -56,11 +56,11 @@ public class ParameterDescriptor {
|
|||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o){
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (o == null || getClass() != o.getClass()){
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public final class Relationship implements Comparable<Relationship> {
|
|||
this.name = builder.name == null ? null : builder.name.intern();
|
||||
this.description = builder.description;
|
||||
this.isAutoTerminate = builder.autoTerminate;
|
||||
this.hashCode = 301 + ( (name == null) ? 0 :this.name.hashCode() ); // compute only once, since it gets called a bunch and will never change
|
||||
this.hashCode = 301 + ( (name == null) ? 0 : this.name.hashCode() ); // compute only once, since it gets called a bunch and will never change
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.apache.nifi.registry.flow;
|
||||
|
||||
public class NoSuchFlowVersionException extends FlowRegistryException{
|
||||
public class NoSuchFlowVersionException extends FlowRegistryException {
|
||||
|
||||
public NoSuchFlowVersionException(final String message) {
|
||||
super(message);
|
||||
|
|
|
@ -69,15 +69,15 @@ public class TestStandardResourceReferences {
|
|||
final int numFiles = 3;
|
||||
|
||||
final File baseDir = new File("target/dirs");
|
||||
for (int i=0; i < numDirs; i++) {
|
||||
for (int i = 0; i < numDirs; i++) {
|
||||
final File dir = new File(baseDir, String.valueOf(i));
|
||||
dir.mkdirs();
|
||||
|
||||
for (int j=0; j < numSubDirs; j++) {
|
||||
for (int j = 0; j < numSubDirs; j++) {
|
||||
final File subdir = new File(dir, String.valueOf(j));
|
||||
subdir.mkdirs();
|
||||
|
||||
for (int k=0; k < numFiles; k++) {
|
||||
for (int k = 0; k < numFiles; k++) {
|
||||
final File file = new File(subdir, k + ".txt");
|
||||
|
||||
try (final OutputStream fos = new FileOutputStream(file)) {
|
||||
|
@ -128,7 +128,7 @@ public class TestStandardResourceReferences {
|
|||
final File baseDir = new File("target/dir");
|
||||
baseDir.mkdirs();
|
||||
|
||||
for (int i=0; i < numFiles; i++) {
|
||||
for (int i = 0; i < numFiles; i++) {
|
||||
final File file = new File(baseDir, i + ".txt");
|
||||
|
||||
try (final OutputStream fos = new FileOutputStream(file)) {
|
||||
|
|
|
@ -76,28 +76,28 @@ public class TestDurationFormat {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings={"1week", "1wk", "1w", "1wks", "1weeks"})
|
||||
@ValueSource(strings = {"1week", "1wk", "1w", "1wks", "1weeks"})
|
||||
public void testGetTimeDurationShouldHandleNoSpaceInInput(String week) {
|
||||
assertEquals(7L, DurationFormat.getTimeDuration(week, TimeUnit.DAYS));
|
||||
}
|
||||
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings={"10 ms", "10 millis", "10 milliseconds"})
|
||||
public void testGetTimeDurationWithWholeNumbers(String whole){
|
||||
@ValueSource(strings = {"10 ms", "10 millis", "10 milliseconds"})
|
||||
public void testGetTimeDurationWithWholeNumbers(String whole) {
|
||||
assertEquals(10L, DurationFormat.getTimeDuration(whole, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings={"0.010 s", "0.010 seconds"})
|
||||
public void testGetTimeDurationWithDecimalNumbers(String decimal){
|
||||
@ValueSource(strings = {"0.010 s", "0.010 seconds"})
|
||||
public void testGetTimeDurationWithDecimalNumbers(String decimal) {
|
||||
assertEquals(10L, DurationFormat.getTimeDuration(decimal, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("getOneWeekInOtherUnits")
|
||||
public void testGetPreciseTimeDurationShouldHandleWeeks(TimeUnit timeUnit, long expected){
|
||||
public void testGetPreciseTimeDurationShouldHandleWeeks(TimeUnit timeUnit, long expected) {
|
||||
assertEquals(expected, DurationFormat.getPreciseTimeDuration("1 week", timeUnit));
|
||||
}
|
||||
|
||||
|
@ -129,13 +129,13 @@ public class TestDurationFormat {
|
|||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings={"10 ms", "10 millis", "10 milliseconds"})
|
||||
@ValueSource(strings = {"10 ms", "10 millis", "10 milliseconds"})
|
||||
public void testGetPreciseTimeDurationWithWholeNumbers(String whole) {
|
||||
assertEquals(10.0, DurationFormat.getPreciseTimeDuration(whole, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings={"0.010 s", "0.010 seconds"})
|
||||
@ValueSource(strings = {"0.010 s", "0.010 seconds"})
|
||||
public void testGetPreciseTimeDurationWithDecimalNumbers(String decimal) {
|
||||
assertEquals(10.0, DurationFormat.getPreciseTimeDuration(decimal, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
|
|
@ -1307,12 +1307,12 @@ public class RunNiFi {
|
|||
final ObjectName osObjectName = ManagementFactory.getOperatingSystemMXBean().getObjectName();
|
||||
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||
final Object maxOpenFileCount = mBeanServer.getAttribute(osObjectName, "MaxFileDescriptorCount");
|
||||
if (maxOpenFileCount!= null) {
|
||||
if (maxOpenFileCount != null) {
|
||||
details.put("maxOpenFileDescriptors", String.valueOf(maxOpenFileCount));
|
||||
}
|
||||
final Object totalPhysicalMemory = mBeanServer.getAttribute(osObjectName, "TotalPhysicalMemorySize");
|
||||
if (totalPhysicalMemory != null) {
|
||||
details.put("totalPhysicalMemoryMB", String.valueOf(((Long) totalPhysicalMemory) / (1024*1024)));
|
||||
details.put("totalPhysicalMemoryMB", String.valueOf(((Long) totalPhysicalMemory) / (1024 * 1024)));
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
// Ignore. This will throw either ClassNotFound or NoClassDefFoundError if unavailable in this JVM.
|
||||
|
@ -1335,7 +1335,7 @@ public class RunNiFi {
|
|||
}
|
||||
|
||||
private Path createSensitiveKeyFile(File confDir) {
|
||||
Path sensitiveKeyFile = Paths.get(confDir+"/sensitive.key");
|
||||
Path sensitiveKeyFile = Paths.get(confDir + "/sensitive.key");
|
||||
|
||||
final boolean isPosixSupported = FileSystems.getDefault().supportedFileAttributeViews().contains("posix");
|
||||
try {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class ShutdownHook extends Thread {
|
|||
if (!statusFile.delete()) {
|
||||
System.err.println("Failed to delete status file " + statusFile.getAbsolutePath() + "; this file should be cleaned up manually");
|
||||
}
|
||||
}catch (IOException ex){
|
||||
} catch (IOException ex) {
|
||||
System.err.println("Failed to retrieve status file " + ex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class SecurityApplicationPropertyHandler implements ApplicationPropertyHa
|
|||
try {
|
||||
trustStore.load(null, null);
|
||||
trustStore.setCertificateEntry(ENTRY_ALIAS, certificate);
|
||||
} catch (final GeneralSecurityException|IOException e) {
|
||||
} catch (final GeneralSecurityException | IOException e) {
|
||||
throw new IllegalStateException("Trust Store creation failed", e);
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class SecurityApplicationPropertyHandler implements ApplicationPropertyHa
|
|||
trustStore.store(outputStream, truststorePasswd.toCharArray());
|
||||
|
||||
applicationProperties.setProperty(SecurityProperty.TRUSTSTORE_PASSWD.getName(), truststorePasswd);
|
||||
} catch (final GeneralSecurityException|IOException e) {
|
||||
} catch (final GeneralSecurityException | IOException e) {
|
||||
throw new IllegalStateException("Trust Store storage failed", e);
|
||||
}
|
||||
}
|
||||
|
@ -136,9 +136,9 @@ public class SecurityApplicationPropertyHandler implements ApplicationPropertyHa
|
|||
final KeyStore keyStore = newKeyStore(storeType);
|
||||
try {
|
||||
keyStore.load(null, null);
|
||||
final X509Certificate[] certificates = new X509Certificate[]{ certificate };
|
||||
final X509Certificate[] certificates = new X509Certificate[]{certificate};
|
||||
keyStore.setKeyEntry(ENTRY_ALIAS, privateKey, password, certificates);
|
||||
} catch (final GeneralSecurityException|IOException e) {
|
||||
} catch (final GeneralSecurityException | IOException e) {
|
||||
throw new IllegalStateException("Key Store creation failed", e);
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ public class SecurityApplicationPropertyHandler implements ApplicationPropertyHa
|
|||
|
||||
applicationProperties.setProperty(SecurityProperty.KEYSTORE_PASSWD.getName(), keystorePasswd);
|
||||
applicationProperties.setProperty(SecurityProperty.KEY_PASSWD.getName(), keystorePasswd);
|
||||
} catch (final GeneralSecurityException|IOException e) {
|
||||
} catch (final GeneralSecurityException | IOException e) {
|
||||
throw new IllegalStateException("Key Store storage failed", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,10 +100,10 @@ public class TestCalciteDatabase {
|
|||
));
|
||||
|
||||
final List<Object[]> rows = List.of(
|
||||
new Object[] { "Mark", 192 },
|
||||
new Object[] { "John Doe", 41 },
|
||||
new Object[] { "Jane Doe", 2910 },
|
||||
new Object[] { "Other", -42 }
|
||||
new Object[] {"Mark", 192},
|
||||
new Object[] {"John Doe", 41},
|
||||
new Object[] {"Jane Doe", 2910},
|
||||
new Object[] {"Other", -42}
|
||||
);
|
||||
final ListDataSource arrayListDataSource = new ListDataSource(tableSchema, rows);
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ public class Query {
|
|||
|
||||
// count number of $$ at end of string
|
||||
int dollars = 0;
|
||||
for (int i=value.length()-1; i >= 0; i--) {
|
||||
for (int i = value.length() - 1; i >= 0; i--) {
|
||||
final char c = value.charAt(i);
|
||||
if (c == '$') {
|
||||
dollars++;
|
||||
|
|
|
@ -180,10 +180,10 @@ final class ValueLookup implements Map<String, String> {
|
|||
newMap.put(entry.getKey().getName(), entry.getValue());
|
||||
}
|
||||
//put attribute maps in reverse order
|
||||
final List<Map<String,String>> listOfMaps = new ArrayList<>(maps);
|
||||
final List<Map<String, String>> listOfMaps = new ArrayList<>(maps);
|
||||
Collections.reverse(listOfMaps);
|
||||
for(final Map<String,String> map : listOfMaps){
|
||||
for(final Map.Entry<String, String> entry : map.entrySet()){
|
||||
for (final Map<String, String> map : listOfMaps) {
|
||||
for (final Map.Entry<String, String> entry : map.entrySet()) {
|
||||
newMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1299,7 +1299,7 @@ public class ExpressionCompiler {
|
|||
|
||||
// count number of $$ at end of string
|
||||
int dollars = 0;
|
||||
for (int i=value.length()-1; i >= 0; i--) {
|
||||
for (int i = value.length() - 1; i >= 0; i--) {
|
||||
final char c = value.charAt(i);
|
||||
if (c == '$') {
|
||||
dollars++;
|
||||
|
|
|
@ -53,14 +53,14 @@ public class DecimalCastEvaluator extends DecimalEvaluator {
|
|||
case STRING:
|
||||
final String trimmed = ((StringQueryResult) result).getValue().trim();
|
||||
NumberParsing.ParseResultType parseType = NumberParsing.parse(trimmed);
|
||||
switch (parseType){
|
||||
switch (parseType) {
|
||||
case DECIMAL:
|
||||
return new DecimalQueryResult(Double.valueOf(trimmed));
|
||||
case WHOLE_NUMBER:
|
||||
Long resultValue;
|
||||
try {
|
||||
resultValue = Long.valueOf(trimmed);
|
||||
} catch (NumberFormatException e){
|
||||
} catch (NumberFormatException e) {
|
||||
// Will only occur if trimmed is a hex number
|
||||
resultValue = Long.decode(trimmed);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class WholeNumberCastEvaluator extends WholeNumberEvaluator {
|
|||
case STRING:
|
||||
final String trimmed = ((StringQueryResult) result).getValue().trim();
|
||||
NumberParsing.ParseResultType parseType = NumberParsing.parse(trimmed);
|
||||
switch (parseType){
|
||||
switch (parseType) {
|
||||
case DECIMAL:
|
||||
final Double doubleResultValue = Double.valueOf(trimmed);
|
||||
return new WholeNumberQueryResult(doubleResultValue.longValue());
|
||||
|
@ -62,7 +62,7 @@ public class WholeNumberCastEvaluator extends WholeNumberEvaluator {
|
|||
Long longResultValue;
|
||||
try {
|
||||
longResultValue = Long.valueOf(trimmed);
|
||||
} catch (NumberFormatException e){
|
||||
} catch (NumberFormatException e) {
|
||||
// Will only occur if trimmed is a hex number
|
||||
longResultValue = Long.decode(trimmed);
|
||||
}
|
||||
|
|
|
@ -25,43 +25,43 @@ import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator;
|
|||
import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult;
|
||||
|
||||
public class CharSequenceTranslatorEvaluator extends StringEvaluator {
|
||||
public static StringEvaluator jsonEscapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator jsonEscapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.ESCAPE_JSON);
|
||||
}
|
||||
|
||||
public static StringEvaluator xmlEscapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator xmlEscapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.ESCAPE_XML10);
|
||||
}
|
||||
|
||||
public static StringEvaluator csvEscapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator csvEscapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.ESCAPE_CSV);
|
||||
}
|
||||
|
||||
public static StringEvaluator html3EscapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator html3EscapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.ESCAPE_HTML3);
|
||||
}
|
||||
|
||||
public static StringEvaluator html4EscapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator html4EscapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.ESCAPE_HTML4);
|
||||
}
|
||||
|
||||
public static StringEvaluator jsonUnescapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator jsonUnescapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.UNESCAPE_JSON);
|
||||
}
|
||||
|
||||
public static StringEvaluator xmlUnescapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator xmlUnescapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.UNESCAPE_XML);
|
||||
}
|
||||
|
||||
public static StringEvaluator csvUnescapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator csvUnescapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.UNESCAPE_CSV);
|
||||
}
|
||||
|
||||
public static StringEvaluator html3UnescapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator html3UnescapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.UNESCAPE_HTML3);
|
||||
}
|
||||
|
||||
public static StringEvaluator html4UnescapeEvaluator(final Evaluator<String> subject){
|
||||
public static StringEvaluator html4UnescapeEvaluator(final Evaluator<String> subject) {
|
||||
return new CharSequenceTranslatorEvaluator(subject, StringEscapeUtils.UNESCAPE_HTML4);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class DivideEvaluator extends NumberEvaluator {
|
|||
}
|
||||
|
||||
final Number result;
|
||||
if (subjectValue instanceof Double || divide instanceof Double){
|
||||
if (subjectValue instanceof Double || divide instanceof Double) {
|
||||
result = subjectValue.doubleValue() / divide.doubleValue();
|
||||
} else {
|
||||
result = subjectValue.longValue() / divide.longValue();
|
||||
|
|
|
@ -44,7 +44,7 @@ public class GreaterThanEvaluator extends BooleanEvaluator {
|
|||
return new BooleanQueryResult(false);
|
||||
}
|
||||
|
||||
if (subjectValue instanceof Double || comparisonValue instanceof Double){
|
||||
if (subjectValue instanceof Double || comparisonValue instanceof Double) {
|
||||
return new BooleanQueryResult(subjectValue.doubleValue() > comparisonValue.doubleValue());
|
||||
} else {
|
||||
return new BooleanQueryResult(subjectValue.longValue() > comparisonValue.longValue());
|
||||
|
|
|
@ -44,7 +44,7 @@ public class GreaterThanOrEqualEvaluator extends BooleanEvaluator {
|
|||
return new BooleanQueryResult(false);
|
||||
}
|
||||
|
||||
if (subjectValue instanceof Double || comparisonValue instanceof Double){
|
||||
if (subjectValue instanceof Double || comparisonValue instanceof Double) {
|
||||
return new BooleanQueryResult(subjectValue.doubleValue() >= comparisonValue.doubleValue());
|
||||
} else {
|
||||
return new BooleanQueryResult(subjectValue.longValue() >= comparisonValue.longValue());
|
||||
|
|
|
@ -57,7 +57,7 @@ public class HashEvaluator extends StringEvaluator {
|
|||
return subject;
|
||||
}
|
||||
|
||||
private MessageDigest getDigest(String algorithm){
|
||||
private MessageDigest getDigest(String algorithm) {
|
||||
try {
|
||||
return MessageDigest.getInstance(algorithm);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class InEvaluator extends BooleanEvaluator {
|
|||
for (Evaluator<String> evaluator : search) {
|
||||
final String searchString = evaluator.evaluate(evaluationContext).getValue();
|
||||
isInList = searchString == null ? false : subjectValue.equals(searchString);
|
||||
if(isInList) {
|
||||
if (isInList) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class LessThanEvaluator extends BooleanEvaluator {
|
|||
return new BooleanQueryResult(false);
|
||||
}
|
||||
|
||||
if (subjectValue instanceof Double || comparisonValue instanceof Double){
|
||||
if (subjectValue instanceof Double || comparisonValue instanceof Double) {
|
||||
return new BooleanQueryResult(subjectValue.doubleValue() < comparisonValue.doubleValue());
|
||||
} else {
|
||||
return new BooleanQueryResult(subjectValue.longValue() < comparisonValue.longValue());
|
||||
|
|
|
@ -44,7 +44,7 @@ public class LessThanOrEqualEvaluator extends BooleanEvaluator {
|
|||
return new BooleanQueryResult(false);
|
||||
}
|
||||
|
||||
if (subjectValue instanceof Double || comparisonValue instanceof Double){
|
||||
if (subjectValue instanceof Double || comparisonValue instanceof Double) {
|
||||
return new BooleanQueryResult(subjectValue.doubleValue() <= comparisonValue.doubleValue());
|
||||
} else {
|
||||
return new BooleanQueryResult(subjectValue.longValue() <= comparisonValue.longValue());
|
||||
|
|
|
@ -46,9 +46,9 @@ public class MathEvaluator extends NumberEvaluator {
|
|||
}
|
||||
|
||||
final Number subjectValue;
|
||||
if(subject != null) {
|
||||
if (subject != null) {
|
||||
subjectValue = subject.evaluate(evaluationContext).getValue();
|
||||
if(subjectValue == null){
|
||||
if (subjectValue == null) {
|
||||
return new NumberQueryResult(null);
|
||||
}
|
||||
} else {
|
||||
|
@ -56,10 +56,10 @@ public class MathEvaluator extends NumberEvaluator {
|
|||
}
|
||||
|
||||
final Number optionalArgValue;
|
||||
if(optionalArg != null) {
|
||||
if (optionalArg != null) {
|
||||
optionalArgValue = optionalArg.evaluate(evaluationContext).getValue();
|
||||
|
||||
if(optionalArgValue == null) {
|
||||
if (optionalArgValue == null) {
|
||||
return new NumberQueryResult(null);
|
||||
}
|
||||
} else {
|
||||
|
@ -69,7 +69,7 @@ public class MathEvaluator extends NumberEvaluator {
|
|||
try {
|
||||
Number executionValue = null;
|
||||
|
||||
if (subjectValue == null){
|
||||
if (subjectValue == null) {
|
||||
Method method;
|
||||
try {
|
||||
method = Math.class.getMethod(methodNamedValue);
|
||||
|
@ -78,28 +78,28 @@ public class MathEvaluator extends NumberEvaluator {
|
|||
methodNamedValue + "'", subjectlessNoMethodException);
|
||||
}
|
||||
|
||||
if(method == null) {
|
||||
if (method == null) {
|
||||
throw new AttributeExpressionLanguageException("Cannot evaluate 'math' function because no subjectless method was found with the name:'" + methodNamedValue + "'");
|
||||
}
|
||||
|
||||
executionValue = (Number) method.invoke(null);
|
||||
|
||||
} else if(optionalArg == null) {
|
||||
} else if (optionalArg == null) {
|
||||
boolean subjectIsDecimal = subjectValue instanceof Double;
|
||||
Method method;
|
||||
try {
|
||||
method = Math.class.getMethod(methodNamedValue, subjectIsDecimal ? double.class : long.class);
|
||||
} catch (NoSuchMethodException noOptionalNoMethodException){
|
||||
} catch (NoSuchMethodException noOptionalNoMethodException) {
|
||||
throw new AttributeExpressionLanguageException("Cannot evaluate 'math' function because no method was found matching the passed parameters:" +
|
||||
" name:'" + methodNamedValue + "', one argument of type: '" + (subjectIsDecimal ? "double" : "long")+"'", noOptionalNoMethodException);
|
||||
" name:'" + methodNamedValue + "', one argument of type: '" + (subjectIsDecimal ? "double" : "long") + "'", noOptionalNoMethodException);
|
||||
}
|
||||
|
||||
if(method == null) {
|
||||
if (method == null) {
|
||||
throw new AttributeExpressionLanguageException("Cannot evaluate 'math' function because no method was found matching the passed parameters:" +
|
||||
" name:'" + methodNamedValue + "', one argument of type: '" + (subjectIsDecimal ? "double" : "long")+"'");
|
||||
" name:'" + methodNamedValue + "', one argument of type: '" + (subjectIsDecimal ? "double" : "long") + "'");
|
||||
}
|
||||
|
||||
if (subjectIsDecimal){
|
||||
if (subjectIsDecimal) {
|
||||
executionValue = (Number) method.invoke(null, subjectValue.doubleValue());
|
||||
} else {
|
||||
executionValue = (Number) method.invoke(null, subjectValue.longValue());
|
||||
|
@ -130,7 +130,7 @@ public class MathEvaluator extends NumberEvaluator {
|
|||
}
|
||||
}
|
||||
|
||||
if(method == null) {
|
||||
if (method == null) {
|
||||
throw new AttributeExpressionLanguageException("Cannot evaluate 'math' function because no method was found matching the passed parameters: " +
|
||||
"name:'" + methodNamedValue + "', first argument type: '" + (subjectIsDecimal ? "double" : "long") + "', second argument type: '"
|
||||
+ (optionalArgIsDecimal ? "double" : "long") + "'");
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MinusEvaluator extends NumberEvaluator {
|
|||
}
|
||||
|
||||
final Number result;
|
||||
if (subjectValue instanceof Double || minus instanceof Double){
|
||||
if (subjectValue instanceof Double || minus instanceof Double) {
|
||||
result = subjectValue.doubleValue() - minus.doubleValue();
|
||||
} else {
|
||||
result = subjectValue.longValue() - minus.longValue();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ModEvaluator extends NumberEvaluator {
|
|||
}
|
||||
|
||||
final Number result;
|
||||
if (subjectValue instanceof Double || mod instanceof Double){
|
||||
if (subjectValue instanceof Double || mod instanceof Double) {
|
||||
result = subjectValue.doubleValue() % mod.doubleValue();
|
||||
} else {
|
||||
result = subjectValue.longValue() % mod.longValue();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MultiplyEvaluator extends NumberEvaluator {
|
|||
}
|
||||
|
||||
final Number result;
|
||||
if (subjectValue instanceof Double || multiply instanceof Double){
|
||||
if (subjectValue instanceof Double || multiply instanceof Double) {
|
||||
result = subjectValue.doubleValue() * multiply.doubleValue();
|
||||
} else {
|
||||
result = subjectValue.longValue() * multiply.longValue();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class PlusEvaluator extends NumberEvaluator {
|
|||
}
|
||||
|
||||
final Number result;
|
||||
if (subjectValue instanceof Double || plus instanceof Double){
|
||||
if (subjectValue instanceof Double || plus instanceof Double) {
|
||||
result = subjectValue.doubleValue() + plus.doubleValue();
|
||||
} else {
|
||||
result = subjectValue.longValue() + plus.longValue();
|
||||
|
|
|
@ -89,7 +89,7 @@ public class StringToDateEvaluator extends DateEvaluator {
|
|||
if ((preparedFormatter == null || !preparedFormatterHasRequestedTimeZone) && timeZone != null) {
|
||||
final QueryResult<String> tzResult = timeZone.evaluate(evaluationContext);
|
||||
final String tz = tzResult.getValue();
|
||||
if(tz != null) {
|
||||
if (tz != null) {
|
||||
dtf = dtf.withZone(ZoneId.of(tz));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class StringLiteralEvaluator extends StringEvaluator {
|
|||
private final String value;
|
||||
|
||||
public StringLiteralEvaluator(final String value) {
|
||||
if(value == null) {
|
||||
if (value == null) {
|
||||
this.value = null;
|
||||
} else {
|
||||
// need to escape characters after backslashes
|
||||
|
|
|
@ -49,11 +49,11 @@ public class NumberParsing {
|
|||
|
||||
// Written according to the "Floating Point Literal" specification as outlined here: http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.2
|
||||
|
||||
private static final String doubleRegex =
|
||||
private static final String doubleRegex =
|
||||
OptionalSign +
|
||||
"(" +
|
||||
Infinity + "|" +
|
||||
NotANumber + "|"+
|
||||
NotANumber + "|" +
|
||||
"(" + Base10Digits + Base10Decimal + ")" + "|" +
|
||||
"(" + Base10Digits + OptionalBase10Decimal + Base10Exponent + ")" + "|" +
|
||||
"(" + Base10Decimal + OptionalBase10Exponent + ")" + "|" +
|
||||
|
@ -73,10 +73,9 @@ public class NumberParsing {
|
|||
private static final Pattern DOUBLE_PATTERN = Pattern.compile(doubleRegex);
|
||||
private static final Pattern NUMBER_PATTERN = Pattern.compile(numberRegex);
|
||||
|
||||
private NumberParsing(){
|
||||
}
|
||||
private NumberParsing() { }
|
||||
|
||||
public static ParseResultType parse(String input){
|
||||
public static ParseResultType parse(String input) {
|
||||
if (NUMBER_PATTERN.matcher(input).matches()) {
|
||||
return ParseResultType.WHOLE_NUMBER;
|
||||
} else if (DOUBLE_PATTERN.matcher(input).matches()) {
|
||||
|
|
|
@ -431,8 +431,8 @@ public class TestQuery {
|
|||
final Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("test", "unit");
|
||||
|
||||
verifyEquals("${#{test}}", attributes, stateValues, parameters,"unit");
|
||||
verifyEquals("${#{test}:append(' - '):append(#{test})}", attributes, stateValues, parameters,"unit - unit");
|
||||
verifyEquals("${#{test}}", attributes, stateValues, parameters, "unit");
|
||||
verifyEquals("${#{test}:append(' - '):append(#{test})}", attributes, stateValues, parameters, "unit - unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -442,15 +442,15 @@ public class TestQuery {
|
|||
final Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("test param", "unit");
|
||||
|
||||
verifyEquals("${#{'test param'}}", attributes, stateValues, parameters,"unit");
|
||||
verifyEquals("${#{'test param'}:append(' - '):append(#{'test param'})}", attributes, stateValues, parameters,"unit - unit");
|
||||
verifyEquals("${#{'test param'}}", attributes, stateValues, parameters, "unit");
|
||||
verifyEquals("${#{'test param'}:append(' - '):append(#{'test param'})}", attributes, stateValues, parameters, "unit - unit");
|
||||
|
||||
verifyEquals("${#{\"test param\"}}", attributes, stateValues, parameters,"unit");
|
||||
verifyEquals("${#{\"test param\"}}", attributes, stateValues, parameters, "unit");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJsonPath() throws IOException {
|
||||
Map<String,String> attributes = verifyJsonPathExpressions(
|
||||
Map<String, String> attributes = verifyJsonPathExpressions(
|
||||
ADDRESS_BOOK_JSON_PATH_EMPTY,
|
||||
"", "${json:jsonPathDelete('$.missingpath')}", "");
|
||||
verifyEquals("${json:jsonPath('$.missingpath')}", attributes, "");
|
||||
|
@ -465,7 +465,7 @@ public class TestQuery {
|
|||
() -> verifyEquals("${invlaid:jsonPath('$.firstName')}", attributes, "John"));
|
||||
}
|
||||
|
||||
private void verifyAddressBookAttributes(String originalAddressBook, Map<String,String> attributes, String updatedAttribute, Object updatedValue) {
|
||||
private void verifyAddressBookAttributes(String originalAddressBook, Map<String, String> attributes, String updatedAttribute, Object updatedValue) {
|
||||
|
||||
if (StringUtils.isBlank(attributes.get("json"))) {
|
||||
throw new IllegalArgumentException("original Json attributes is empty");
|
||||
|
@ -481,17 +481,17 @@ public class TestQuery {
|
|||
verifyEquals(currentAttribute, attributes, expected);
|
||||
}
|
||||
);
|
||||
if (! ADDRESS_BOOK_JSON_PATH_EMPTY.equals(updatedAttribute) ) {
|
||||
if (!ADDRESS_BOOK_JSON_PATH_EMPTY.equals(updatedAttribute) ) {
|
||||
verifyEquals(updatedAttribute, attributes, updatedValue);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String,String> verifyJsonPathExpressions(String targetAttribute, Object originalValue, String updateExpression, Object updatedValue) throws IOException {
|
||||
private Map<String, String> verifyJsonPathExpressions(String targetAttribute, Object originalValue, String updateExpression, Object updatedValue) throws IOException {
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
String addressBook = getResourceAsString("/json/address-book.json");
|
||||
attributes.put("json", addressBook);
|
||||
|
||||
if ( ! ADDRESS_BOOK_JSON_PATH_EMPTY.equals(targetAttribute) ) {
|
||||
if ( !ADDRESS_BOOK_JSON_PATH_EMPTY.equals(targetAttribute) ) {
|
||||
verifyEquals(targetAttribute, attributes, originalValue);
|
||||
}
|
||||
|
||||
|
@ -579,7 +579,7 @@ public class TestQuery {
|
|||
|
||||
@Test
|
||||
public void testJsonPathAddNicknameJimmy() throws IOException {
|
||||
Map<String,String> attributes = verifyJsonPathExpressions(
|
||||
Map<String, String> attributes = verifyJsonPathExpressions(
|
||||
ADDRESS_BOOK_JSON_PATH_EMPTY,
|
||||
"",
|
||||
"${json:jsonPathAdd('$.nicknames', 'Jimmy')}",
|
||||
|
@ -589,7 +589,7 @@ public class TestQuery {
|
|||
|
||||
@Test
|
||||
public void testJsonPathAddNicknameJimmyAtNonexistantPath() throws IOException {
|
||||
Map<String,String> attributes = verifyJsonPathExpressions(
|
||||
Map<String, String> attributes = verifyJsonPathExpressions(
|
||||
ADDRESS_BOOK_JSON_PATH_EMPTY,
|
||||
"",
|
||||
"${json:jsonPathAdd('$.missing-path', 'Jimmy')}",
|
||||
|
@ -608,7 +608,7 @@ public class TestQuery {
|
|||
|
||||
@Test
|
||||
public void testJsonPathPutRootLevelMiddlenameTuron() throws IOException {
|
||||
Map<String,String> attributes = verifyJsonPathExpressions(
|
||||
Map<String, String> attributes = verifyJsonPathExpressions(
|
||||
ADDRESS_BOOK_JSON_PATH_EMPTY,
|
||||
"",
|
||||
"${json:jsonPathPut('$','middlename','Turon')}",
|
||||
|
@ -618,7 +618,7 @@ public class TestQuery {
|
|||
|
||||
@Test
|
||||
public void testJsonPathPutCountryToMap() throws IOException {
|
||||
Map<String,String> attributes = verifyJsonPathExpressions(
|
||||
Map<String, String> attributes = verifyJsonPathExpressions(
|
||||
ADDRESS_BOOK_JSON_PATH_EMPTY,
|
||||
"",
|
||||
"${json:jsonPathPut('$.address','country','US')}",
|
||||
|
@ -628,7 +628,7 @@ public class TestQuery {
|
|||
|
||||
@Test
|
||||
public void testJsonPathPutElementToArray() throws IOException {
|
||||
Map<String,String> attributes = verifyJsonPathExpressions(
|
||||
Map<String, String> attributes = verifyJsonPathExpressions(
|
||||
ADDRESS_BOOK_JSON_PATH_EMPTY,
|
||||
"",
|
||||
"${json:jsonPathPut('$.phoneNumbers[1]', 'backup', '212-555-1212')}",
|
||||
|
@ -1233,9 +1233,9 @@ public class TestQuery {
|
|||
"repeating", StringUtils.repeat(originalValue, " ", n));
|
||||
|
||||
final String replacementValue = "Goodbye Planet";
|
||||
final String expectedRepeatingResult = replacementValue + " " + StringUtils.repeat(originalValue, " ", n -1);
|
||||
final String expectedRepeatingResult = replacementValue + " " + StringUtils.repeat(originalValue, " ", n - 1);
|
||||
final String replaceOnlyFirstPattern = "\\w+\\s\\w+\\b??";
|
||||
final String replaceSingleExpression = "${single:replaceFirst('" + replaceOnlyFirstPattern +"', '" + replacementValue + "')}";
|
||||
final String replaceSingleExpression = "${single:replaceFirst('" + replaceOnlyFirstPattern + "', '" + replacementValue + "')}";
|
||||
final String replaceRepeatingExpression = "${repeating:replaceFirst('" + replaceOnlyFirstPattern + "', '" + replacementValue + "')}";
|
||||
Query replaceSingleQuery = Query.compile(replaceSingleExpression);
|
||||
Query replaceRepeatingQuery = Query.compile(replaceRepeatingExpression);
|
||||
|
@ -1256,7 +1256,7 @@ public class TestQuery {
|
|||
final Map<String, String> attributes = Map.of("single", originalValue,
|
||||
"repeating", StringUtils.repeat(originalValue, " ", n));
|
||||
final String replacementValue = "Goodbye Planet";
|
||||
final String expectedRepeatingResult = replacementValue + " " + StringUtils.repeat(originalValue, " ", n -1);
|
||||
final String expectedRepeatingResult = replacementValue + " " + StringUtils.repeat(originalValue, " ", n - 1);
|
||||
final String replaceSingleExpression = "${single:replaceFirst('" + originalValue + "', '" + replacementValue + "')}";
|
||||
final String replaceRepeatingExpression = "${repeating:replaceFirst('" + originalValue + "', '" + replacementValue + "')}";
|
||||
Query replaceSingleQuery = Query.compile(replaceSingleExpression);
|
||||
|
@ -1278,7 +1278,7 @@ public class TestQuery {
|
|||
final Map<String, String> attributes = Map.of("single", originalValue,
|
||||
"repeating", StringUtils.repeat(originalValue, " ", n));
|
||||
final String replacementValue = "Goodbye Planet";
|
||||
final String expectedRepeatingResult = replacementValue + " " + StringUtils.repeat(originalValue, " ", n -1);
|
||||
final String expectedRepeatingResult = replacementValue + " " + StringUtils.repeat(originalValue, " ", n - 1);
|
||||
final String replaceOnlyFirstPattern = "\\w+\\s\\w+\\b??";
|
||||
|
||||
// Execute on both single and repeating with String#replace()
|
||||
|
@ -1319,7 +1319,7 @@ public class TestQuery {
|
|||
attributes.put("hundred", "100");
|
||||
|
||||
// The expected resulted is calculated instead of a set number due to the inaccuracy of double arithmetic
|
||||
verifyEquals("${hundred:toNumber():multiply(${second}):divide(${third}):plus(${first}):mod(${fifth})}", attributes, (((100 * 12.3) / 3) + 1.5) %5.1);
|
||||
verifyEquals("${hundred:toNumber():multiply(${second}):divide(${third}):plus(${first}):mod(${fifth})}", attributes, (((100 * 12.3) / 3) + 1.5) % 5.1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1380,11 +1380,11 @@ public class TestQuery {
|
|||
verifyEquals("${negative:math('max', ${two})}", attributes, 2L);
|
||||
verifyEquals("${negativeDecimal:math('max', ${twoDecimal})}", attributes, 2.3D);
|
||||
|
||||
verifyEquals("${oneDecimal:math('pow', ${two:toDecimal()})}", attributes, Math.pow(1.5,2));
|
||||
verifyEquals("${oneDecimal:math('scalb', ${two})}", attributes, Math.scalb(1.5,2));
|
||||
verifyEquals("${oneDecimal:math('pow', ${two:toDecimal()})}", attributes, Math.pow(1.5, 2));
|
||||
verifyEquals("${oneDecimal:math('scalb', ${two})}", attributes, Math.scalb(1.5, 2));
|
||||
|
||||
verifyEquals("${negative:math('abs'):toDecimal():math('cbrt'):math('max', ${two:toDecimal():math('pow',${oneDecimal}):mod(${two})})}", attributes,
|
||||
Math.max(Math.cbrt(Math.abs(-64)), Math.pow(2,1.5)%2));
|
||||
Math.max(Math.cbrt(Math.abs(-64)), Math.pow(2, 1.5) % 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1394,8 +1394,8 @@ public class TestQuery {
|
|||
attributes.put("two", "2.2");
|
||||
|
||||
// The expected resulted is calculated instead of a set number due to the inaccuracy of double arithmetic
|
||||
verifyEquals("${literal(5):toNumber():multiply(${two:plus(1)})}", attributes, 5*3.2);
|
||||
verifyEquals("${literal(5.5E-1):toDecimal():plus(${literal(.5E1)}):multiply(${two:plus(1)})}", attributes, (0.55+5)*3.2);
|
||||
verifyEquals("${literal(5):toNumber():multiply(${two:plus(1)})}", attributes, 5 * 3.2);
|
||||
verifyEquals("${literal(5.5E-1):toDecimal():plus(${literal(.5E1)}):multiply(${two:plus(1)})}", attributes, (0.55 + 5) * 3.2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1937,7 +1937,7 @@ public class TestQuery {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBase64Encode(){
|
||||
public void testBase64Encode() {
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
attributes.put("userpass", "admin:admin");
|
||||
verifyEquals("${userpass:base64Encode()}", attributes, "YWRtaW46YWRtaW4=");
|
||||
|
@ -1945,7 +1945,7 @@ public class TestQuery {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBase64Decode(){
|
||||
public void testBase64Decode() {
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
attributes.put("userpassbase64", "YWRtaW46YWRtaW4=");
|
||||
verifyEquals("${userpassbase64:base64Decode()}", attributes, "admin:admin");
|
||||
|
@ -2536,7 +2536,7 @@ public class TestQuery {
|
|||
}
|
||||
|
||||
private void verifyEquals(final String expression, final Map<String, String> attributes, final Object expectedResult) {
|
||||
verifyEquals(expression,attributes, null, ParameterLookup.EMPTY, expectedResult);
|
||||
verifyEquals(expression, attributes, null, ParameterLookup.EMPTY, expectedResult);
|
||||
}
|
||||
|
||||
private void verifyEquals(final String expression, final Map<String, String> attributes, final Map<String, String> stateValues, final Object expectedResult) {
|
||||
|
@ -2564,7 +2564,7 @@ public class TestQuery {
|
|||
} else {
|
||||
assertEquals(ResultType.WHOLE_NUMBER, result.getResultType());
|
||||
}
|
||||
} else if(expectedResult instanceof Double) {
|
||||
} else if (expectedResult instanceof Double) {
|
||||
if (ResultType.NUMBER.equals(result.getResultType())) {
|
||||
final Number resultNumber = ((NumberQueryResult) result).getValue();
|
||||
assertTrue(resultNumber instanceof Double);
|
||||
|
|
|
@ -34,7 +34,7 @@ public class JsonFlowEncryptor extends AbstractFlowEncryptor {
|
|||
public void processFlow(final InputStream inputStream, final OutputStream outputStream,
|
||||
final PropertyEncryptor inputEncryptor, final PropertyEncryptor outputEncryptor) {
|
||||
final JsonFactory factory = new JsonFactory();
|
||||
try (final JsonGenerator generator = factory.createGenerator(outputStream)){
|
||||
try (final JsonGenerator generator = factory.createGenerator(outputStream)) {
|
||||
try (final JsonParser parser = factory.createParser(inputStream)) {
|
||||
parser.setCodec(new ObjectMapper());
|
||||
processJsonByTokens(parser, generator, inputEncryptor, outputEncryptor);
|
||||
|
|
|
@ -78,7 +78,7 @@ public class FlowFilePackagerV1 implements FlowFilePackager {
|
|||
entry.setMode(tarPermissions);
|
||||
entry.setSize(fileSize);
|
||||
tarOut.putArchiveEntry(entry);
|
||||
final byte[] buffer = new byte[512 << 10];//512KB
|
||||
final byte[] buffer = new byte[512 << 10]; //512KB
|
||||
int bytesRead = 0;
|
||||
while ((bytesRead = inStream.read(buffer)) != -1) { //still more data to read
|
||||
if (bytesRead > 0) {
|
||||
|
|
|
@ -94,8 +94,8 @@ public class FlowFilePackagerV2 implements FlowFilePackager {
|
|||
writeString(entry.getKey(), out);
|
||||
writeString(entry.getValue(), out);
|
||||
}
|
||||
writeLong(out, fileSize);//write out length of data
|
||||
copy(in, out);//write out the actual flow file payload
|
||||
writeLong(out, fileSize); //write out length of data
|
||||
copy(in, out); //write out the actual flow file payload
|
||||
}
|
||||
|
||||
private void copy(final InputStream in, final OutputStream out) throws IOException {
|
||||
|
|
|
@ -41,8 +41,8 @@ public class FlowFilePackagerV3 implements FlowFilePackager {
|
|||
}
|
||||
}
|
||||
|
||||
writeLong(out, fileSize);//write out length of data
|
||||
copy(in, out);//write out the actual flow file payload
|
||||
writeLong(out, fileSize); //write out length of data
|
||||
copy(in, out); //write out the actual flow file payload
|
||||
}
|
||||
|
||||
private void copy(final InputStream in, final OutputStream out) throws IOException {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class FlowFileUnpackagerV1 implements FlowFileUnpackager {
|
|||
final TarArchiveEntry contentEntry = tarIn.getNextEntry();
|
||||
|
||||
if (contentEntry != null && contentEntry.getName().equals(FlowFilePackagerV1.FILENAME_CONTENT)) {
|
||||
final byte[] buffer = new byte[512 << 10];//512KB
|
||||
final byte[] buffer = new byte[512 << 10]; //512KB
|
||||
int bytesRead = 0;
|
||||
while ((bytesRead = tarIn.read(buffer)) != -1) { //still more data to read
|
||||
if (bytesRead > 0) {
|
||||
|
|
|
@ -44,7 +44,7 @@ public class HashiCorpVaultProperties {
|
|||
this.uri = Objects.requireNonNull(builder.uri, "Vault URI is required");;
|
||||
this.authPropertiesFilename = Objects.requireNonNull(builder.authPropertiesFilename, "Vault auth properties filename is required");
|
||||
this.ssl = new HashiCorpVaultSslProperties(builder.keyStore, builder.keyStoreType, builder.keyStorePassword,
|
||||
builder.trustStore, builder.trustStoreType, builder.trustStorePassword,builder.enabledTlsCipherSuites, builder.enabledTlsProtocols);
|
||||
builder.trustStore, builder.trustStoreType, builder.trustStorePassword, builder.enabledTlsCipherSuites, builder.enabledTlsProtocols);
|
||||
this.connectionTimeout = builder.connectionTimeout == null ? Optional.empty() : Optional.of(builder.connectionTimeout);
|
||||
this.readTimeout = builder.readTimeout == null ? Optional.empty() : Optional.of(builder.readTimeout);
|
||||
this.kvVersion = builder.kvVersion;
|
||||
|
|
|
@ -57,7 +57,7 @@ public class BeanPropertyLookup extends PropertyLookup {
|
|||
private static String getPropertyKey(final String prefix, final PropertyDescriptor propertyDescriptor) {
|
||||
final HashiCorpVaultProperty propertyAnnotation = propertyDescriptor.getReadMethod().getAnnotation(HashiCorpVaultProperty.class);
|
||||
final String unqualifiedPropertyKey = !propertyAnnotation.key().isEmpty() ? propertyAnnotation.key() : propertyDescriptor.getDisplayName();
|
||||
return prefix == null ? unqualifiedPropertyKey: String.join(SEPARATOR, prefix, unqualifiedPropertyKey);
|
||||
return prefix == null ? unqualifiedPropertyKey : String.join(SEPARATOR, prefix, unqualifiedPropertyKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,7 @@ public class BeanPropertyLookup extends PropertyLookup {
|
|||
final PropertyLookup propertyLookup = propertyLookupMap.get(propertyKey);
|
||||
return propertyLookup.getPropertyValue(propertyKey, propertyLookup.getEnclosingObject(obj));
|
||||
}
|
||||
for(final Map.Entry<String, PropertyLookup> entry : propertyLookupMap.entrySet()) {
|
||||
for (final Map.Entry<String, PropertyLookup> entry : propertyLookupMap.entrySet()) {
|
||||
final String key = entry.getKey();
|
||||
if (propertyKey.startsWith(key + SEPARATOR)) {
|
||||
final PropertyLookup propertyLookup = entry.getValue();
|
||||
|
|
|
@ -47,7 +47,7 @@ class StandardServerConnectorFactoryTest {
|
|||
|
||||
private static final int HTTPS_PORT = 8443;
|
||||
|
||||
private static final String[] INCLUDE_PROTOCOLS = new String[]{ "TLSv1.2" };
|
||||
private static final String[] INCLUDE_PROTOCOLS = new String[]{"TLSv1.2"};
|
||||
|
||||
@Test
|
||||
void testGetServerConnector() {
|
||||
|
|
|
@ -263,7 +263,7 @@ public interface JvmMetrics {
|
|||
* available
|
||||
*/
|
||||
public long getMemoryUsed(DataUnit dataUnit) {
|
||||
return (long)dataUnit.convert(memoryUsed, DataUnit.B);
|
||||
return (long) dataUnit.convert(memoryUsed, DataUnit.B);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,13 +32,13 @@ public abstract class AbstractParameterParser implements ParameterParser {
|
|||
}
|
||||
|
||||
|
||||
final int numEscapedStartTags = (sequentialStartTags - 1)/2;
|
||||
final int numEscapedStartTags = (sequentialStartTags - 1) / 2;
|
||||
final int startOffset = startCharIndex + numEscapedStartTags * 2;
|
||||
final String referenceText = input.substring(startOffset, endCharIndex + 1);
|
||||
|
||||
// If we have multiple escapes before the start tag, we need to add a StartCharacterEscape for each one.
|
||||
// For example, if we have ###{foo}, then we should end up with a StartCharacterEscape followed by an actual Parameter Reference.
|
||||
for (int escapes=0; escapes < numEscapedStartTags; escapes++) {
|
||||
for (int escapes = 0; escapes < numEscapedStartTags; escapes++) {
|
||||
tokens.add(new StartCharacterEscape(startCharIndex + escapes * 2));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public class ExpressionLanguageAgnosticParameterParser extends AbstractParameter
|
|||
final List<ParameterToken> references = new ArrayList<>();
|
||||
int sequentialStartTags = 0;
|
||||
|
||||
for (int i=0; i < input.length(); i++) {
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
final char c = input.charAt(i);
|
||||
|
||||
switch (c) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ExpressionLanguageAwareParameterParser extends AbstractParameterPar
|
|||
int embeddedElCount = 0;
|
||||
int expressionStart = -1;
|
||||
|
||||
for (int i=0; i < input.length(); i++) {
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
final char c = input.charAt(i);
|
||||
|
||||
switch (c) {
|
||||
|
|
|
@ -149,11 +149,11 @@ public class NiFiPropertiesTest {
|
|||
assertTrue(scopes.contains(scopeLeadingTrailingWhitespace.trim()));
|
||||
}
|
||||
|
||||
private NiFiProperties loadNiFiProperties(final String propsPath, final Map<String, String> additionalProperties){
|
||||
private NiFiProperties loadNiFiProperties(final String propsPath, final Map<String, String> additionalProperties) {
|
||||
String realPath = null;
|
||||
try{
|
||||
try {
|
||||
realPath = NiFiPropertiesTest.class.getResource(propsPath).toURI().getPath();
|
||||
}catch(final URISyntaxException ex){
|
||||
} catch (final URISyntaxException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
return NiFiProperties.createBasicNiFiProperties(realPath, additionalProperties);
|
||||
|
|
|
@ -140,7 +140,7 @@ public class AwsSecretsManagerSensitivePropertyProvider implements SensitiveProp
|
|||
throw new SensitivePropertyProtectionException(String.format("AWS Secrets Manager Secret [%s] JSON parsing failed",
|
||||
context.getContextKey()));
|
||||
}
|
||||
return Optional.of((ObjectNode) responseNode) ;
|
||||
return Optional.of((ObjectNode) responseNode);
|
||||
} catch (final ResourceNotFoundException e) {
|
||||
return Optional.empty();
|
||||
} catch (final SecretsManagerException e) {
|
||||
|
|
|
@ -106,7 +106,7 @@ public class BootstrapProperties extends StandardReadableProperties {
|
|||
private void filterProperties(final Properties properties) {
|
||||
getRawProperties().clear();
|
||||
final Properties filteredProperties = new Properties();
|
||||
for(final Enumeration<Object> e = properties.keys() ; e.hasMoreElements(); ) {
|
||||
for (final Enumeration<Object> e = properties.keys(); e.hasMoreElements(); ) {
|
||||
final String key = e.nextElement().toString();
|
||||
if (key.startsWith(propertyPrefix)) {
|
||||
filteredProperties.put(key, properties.getProperty(key));
|
||||
|
|
|
@ -51,7 +51,7 @@ public class StandardReadableProperties implements ReadableProperties {
|
|||
public Set<String> getPropertyKeys() {
|
||||
Set<String> propertyNames = new HashSet<>();
|
||||
Enumeration e = rawProperties.propertyNames();
|
||||
for (; e.hasMoreElements(); ){
|
||||
for (; e.hasMoreElements(); ) {
|
||||
propertyNames.add((String) e.nextElement());
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class Hash extends RecordPathSegment {
|
|||
});
|
||||
}
|
||||
|
||||
private MessageDigest getDigest(String algorithm){
|
||||
private MessageDigest getDigest(String algorithm) {
|
||||
try {
|
||||
return MessageDigest.getInstance(algorithm);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MapOf extends RecordPathSegment {
|
|||
|
||||
for (int i = 0; i + 1 < valuePaths.length; i += 2) {
|
||||
final String key = valuePaths[i].evaluate(context).findFirst().get().toString();
|
||||
final String value = valuePaths[i+1].evaluate(context).findFirst().get().toString();
|
||||
final String value = valuePaths[i + 1].evaluate(context).findFirst().get().toString();
|
||||
fields.add(new RecordField(key, RecordFieldType.STRING.getDataType()));
|
||||
values.put(key, value);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ abstract class Padding extends RecordPathSegment {
|
|||
this.desiredLengthPath = desiredLengthPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<FieldValue> evaluate(RecordPathEvaluationContext context) {
|
||||
String pad = getPaddingString(context);
|
||||
|
||||
|
@ -90,7 +91,7 @@ abstract class Padding extends RecordPathSegment {
|
|||
return OptionalInt.of(DataTypeUtils.toInteger(length, fieldName));
|
||||
}
|
||||
|
||||
private String getPaddingString(RecordPathEvaluationContext context){
|
||||
private String getPaddingString(RecordPathEvaluationContext context) {
|
||||
|
||||
if (null == paddingStringPath) {
|
||||
return DEFAULT_PADDING_STRING;
|
||||
|
@ -98,7 +99,7 @@ abstract class Padding extends RecordPathSegment {
|
|||
|
||||
String padStr = RecordPathUtils.getFirstStringValue(paddingStringPath, context);
|
||||
|
||||
if (null != padStr && !padStr.isEmpty()){
|
||||
if (null != padStr && !padStr.isEmpty()) {
|
||||
return padStr;
|
||||
}
|
||||
return DEFAULT_PADDING_STRING;
|
||||
|
|
|
@ -70,7 +70,7 @@ public class UUID5 extends RecordPathSegment {
|
|||
Object rawValue = value.getValue();
|
||||
|
||||
if (rawValue instanceof String) {
|
||||
return Optional.of((String)rawValue);
|
||||
return Optional.of((String) rawValue);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ public class RecordPathCompiler {
|
|||
case "mapOf": {
|
||||
final int numArgs = argumentListTree.getChildCount();
|
||||
|
||||
if(numArgs % 2 != 0) {
|
||||
if (numArgs % 2 != 0) {
|
||||
throw new RecordPathException("The mapOf function requires an even number of arguments");
|
||||
}
|
||||
|
||||
|
@ -358,7 +358,7 @@ public class RecordPathCompiler {
|
|||
|
||||
return new UnescapeJson(args[0], convertToRecord, recursiveConversion, absolute);
|
||||
}
|
||||
case "hash":{
|
||||
case "hash": {
|
||||
final RecordPathSegment[] args = getArgPaths(argumentListTree, 2, functionName, absolute);
|
||||
return new Hash(args[0], args[1], absolute);
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ public class RecordPathCompiler {
|
|||
}
|
||||
|
||||
final List<RecordPathSegment> argPaths = new ArrayList<>();
|
||||
for (int i=0; i < argumentListTree.getChildCount(); i++) {
|
||||
for (int i = 0; i < argumentListTree.getChildCount(); i++) {
|
||||
argPaths.add(buildPath(argumentListTree.getChild(i), null, absolute));
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ public class FieldValueLogicalPathBuilder {
|
|||
}
|
||||
});
|
||||
Collections.reverse(paths);
|
||||
return String.join("",paths);
|
||||
return String.join("", paths);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class DataTypeUtils {
|
|||
OptionalSign +
|
||||
"(" +
|
||||
Infinity + "|" +
|
||||
NotANumber + "|"+
|
||||
NotANumber + "|" +
|
||||
"(" + Base10Digits + OptionalBase10Decimal + ")" + "|" +
|
||||
"(" + Base10Digits + OptionalBase10Decimal + Base10Exponent + ")" + "|" +
|
||||
"(" + Base10Decimal + OptionalBase10Exponent + ")" +
|
||||
|
@ -233,7 +233,7 @@ public class DataTypeUtils {
|
|||
case UUID:
|
||||
return toUUID(value);
|
||||
case ARRAY:
|
||||
return toArray(value, fieldName, ((ArrayDataType)dataType).getElementType(), charset);
|
||||
return toArray(value, fieldName, ((ArrayDataType) dataType).getElementType(), charset);
|
||||
case MAP:
|
||||
return toMap(value, fieldName);
|
||||
case RECORD:
|
||||
|
@ -266,14 +266,14 @@ public class DataTypeUtils {
|
|||
|
||||
if (value instanceof String) {
|
||||
try {
|
||||
return UUID.fromString((String)value);
|
||||
return UUID.fromString((String) value);
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalTypeConversionException(String.format("Could not parse %s into a UUID", value), ex);
|
||||
}
|
||||
} else if (value instanceof byte[]) {
|
||||
return uuidFromBytes((byte[])value);
|
||||
return uuidFromBytes((byte[]) value);
|
||||
} else if (value instanceof Byte[]) {
|
||||
Byte[] array = (Byte[])value;
|
||||
Byte[] array = (Byte[]) value;
|
||||
byte[] converted = new byte[array.length];
|
||||
for (int x = 0; x < array.length; x++) {
|
||||
converted[x] = array[x];
|
||||
|
@ -657,7 +657,7 @@ public class DataTypeUtils {
|
|||
DataType mergedDataType = null;
|
||||
|
||||
int length = Array.getLength(value);
|
||||
for(int index = 0; index < length; index++) {
|
||||
for (int index = 0; index < length; index++) {
|
||||
final DataType inferredDataType = inferDataType(Array.get(value, index), RecordFieldType.STRING.getDataType());
|
||||
mergedDataType = mergeDataTypes(mergedDataType, inferredDataType);
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ public class DataTypeUtils {
|
|||
|
||||
if (strict) {
|
||||
if (value instanceof Record) {
|
||||
if (!schema.getFieldNames().containsAll(((Record)value).getRawFieldNames())) {
|
||||
if (!schema.getFieldNames().containsAll(((Record) value).getRawFieldNames())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ public class DataTypeUtils {
|
|||
}
|
||||
|
||||
if (value instanceof UUID) {
|
||||
UUID uuid = (UUID)value;
|
||||
UUID uuid = (UUID) value;
|
||||
ByteBuffer buffer = ByteBuffer.allocate(16);
|
||||
buffer.putLong(uuid.getMostSignificantBits());
|
||||
buffer.putLong(uuid.getLeastSignificantBits());
|
||||
|
@ -801,7 +801,7 @@ public class DataTypeUtils {
|
|||
}
|
||||
|
||||
if (value instanceof List) {
|
||||
final List<?> list = (List<?>)value;
|
||||
final List<?> list = (List<?>) value;
|
||||
return list.toArray();
|
||||
}
|
||||
|
||||
|
@ -809,7 +809,7 @@ public class DataTypeUtils {
|
|||
if (value instanceof Blob) {
|
||||
Blob blob = (Blob) value;
|
||||
long rawBlobLength = blob.length();
|
||||
if(rawBlobLength > Integer.MAX_VALUE) {
|
||||
if (rawBlobLength > Integer.MAX_VALUE) {
|
||||
throw new IllegalTypeConversionException("Value of type " + value.getClass() + " too large to convert to Object Array for field " + fieldName);
|
||||
}
|
||||
int blobLength = (int) rawBlobLength;
|
||||
|
@ -1026,13 +1026,13 @@ public class DataTypeUtils {
|
|||
}
|
||||
|
||||
if (value instanceof byte[]) {
|
||||
return new String((byte[])value, charset);
|
||||
return new String((byte[]) value, charset);
|
||||
}
|
||||
|
||||
if (value instanceof Byte[]) {
|
||||
Byte[] src = (Byte[]) value;
|
||||
byte[] dest = new byte[src.length];
|
||||
for(int i=0;i<src.length;i++) {
|
||||
for (int i = 0; i < src.length; i++) {
|
||||
dest[i] = src[i];
|
||||
}
|
||||
return new String(dest, charset);
|
||||
|
@ -1156,7 +1156,7 @@ public class DataTypeUtils {
|
|||
}
|
||||
|
||||
public static Object toEnum(Object value, EnumDataType dataType, String fieldName) {
|
||||
if(dataType.getEnums() != null && dataType.getEnums().contains(value)) {
|
||||
if (dataType.getEnums() != null && dataType.getEnums().contains(value)) {
|
||||
return value.toString();
|
||||
}
|
||||
throw new IllegalTypeConversionException("Cannot convert value " + value + " of type " + dataType + " for field " + fieldName);
|
||||
|
@ -2040,7 +2040,7 @@ public class DataTypeUtils {
|
|||
}
|
||||
|
||||
public static Charset getCharset(String charsetName) {
|
||||
if(charsetName == null) {
|
||||
if (charsetName == null) {
|
||||
return StandardCharsets.UTF_8;
|
||||
} else {
|
||||
return Charset.forName(charsetName);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class ResultSetRecordSetTest {
|
|||
new TestColumn(11, COLUMN_NAME_FLOAT, Types.FLOAT, RecordFieldType.FLOAT.getDataType()),
|
||||
new TestColumn(12, COLUMN_NAME_SMALLINT, Types.SMALLINT, RecordFieldType.SHORT.getDataType()),
|
||||
new TestColumn(13, COLUMN_NAME_TINYINT, Types.TINYINT, RecordFieldType.BYTE.getDataType()),
|
||||
new TestColumn(14, COLUMN_NAME_BIG_DECIMAL_1, Types.DECIMAL,RecordFieldType.DECIMAL.getDecimalDataType(7, 3)),
|
||||
new TestColumn(14, COLUMN_NAME_BIG_DECIMAL_1, Types.DECIMAL, RecordFieldType.DECIMAL.getDecimalDataType(7, 3)),
|
||||
new TestColumn(15, COLUMN_NAME_BIG_DECIMAL_2, Types.NUMERIC, RecordFieldType.DECIMAL.getDecimalDataType(4, 0)),
|
||||
new TestColumn(16, COLUMN_NAME_BIG_DECIMAL_3, Types.JAVA_OBJECT, RecordFieldType.DECIMAL.getDecimalDataType(501, 1)),
|
||||
new TestColumn(17, COLUMN_NAME_BIG_DECIMAL_4, Types.DECIMAL, RecordFieldType.DECIMAL.getDecimalDataType(10, 3)),
|
||||
|
@ -362,7 +362,7 @@ public class ResultSetRecordSetTest {
|
|||
when(resultSetMetaData.getColumnType(1)).thenReturn(Types.DECIMAL);
|
||||
|
||||
// when
|
||||
ResultSetRecordSet testSubject = new ResultSetRecordSet(resultSet, recordSchema, 10,0, false);
|
||||
ResultSetRecordSet testSubject = new ResultSetRecordSet(resultSet, recordSchema, 10, 0, false);
|
||||
final RecordSchema resultSchema = testSubject.getSchema();
|
||||
|
||||
// then
|
||||
|
@ -429,7 +429,7 @@ public class ResultSetRecordSetTest {
|
|||
List<RecordField> fields = whenSchemaFieldsAreSetupForArrayType(testData, resultSet, resultSetMetaData);
|
||||
RecordSchema recordSchema = new SimpleRecordSchema(fields);
|
||||
|
||||
ResultSetRecordSet testSubject = new ResultSetRecordSet(resultSet, recordSchema, 10,0, useLogicalTypes);
|
||||
ResultSetRecordSet testSubject = new ResultSetRecordSet(resultSet, recordSchema, 10, 0, useLogicalTypes);
|
||||
RecordSchema actualSchema = testSubject.getSchema();
|
||||
|
||||
// THEN
|
||||
|
@ -444,7 +444,7 @@ public class ResultSetRecordSetTest {
|
|||
new TestColumn(3, "time_with_timezone", Types.TIME_WITH_TIMEZONE, RecordFieldType.TIME.getDataType()),
|
||||
new TestColumn(4, "timestamp", Types.TIMESTAMP, RecordFieldType.TIMESTAMP.getDataType()),
|
||||
new TestColumn(5, "timestamp_with_timezone", Types.TIMESTAMP_WITH_TIMEZONE, RecordFieldType.TIMESTAMP.getDataType()),
|
||||
new TestColumn(6, COLUMN_NAME_BIG_DECIMAL_1, Types.DECIMAL,RecordFieldType.DECIMAL.getDecimalDataType(7, 3)),
|
||||
new TestColumn(6, COLUMN_NAME_BIG_DECIMAL_1, Types.DECIMAL, RecordFieldType.DECIMAL.getDecimalDataType(7, 3)),
|
||||
new TestColumn(7, COLUMN_NAME_BIG_DECIMAL_2, Types.NUMERIC, RecordFieldType.DECIMAL.getDecimalDataType(4, 0)),
|
||||
new TestColumn(8, COLUMN_NAME_BIG_DECIMAL_3, Types.JAVA_OBJECT, RecordFieldType.DECIMAL.getDecimalDataType(501, 1)),
|
||||
new TestColumn(9, COLUMN_NAME_BIG_DECIMAL_4, Types.DECIMAL, RecordFieldType.DECIMAL.getDecimalDataType(10, 3)),
|
||||
|
@ -460,7 +460,7 @@ public class ResultSetRecordSetTest {
|
|||
// WHEN
|
||||
setUpMocks(columns, resultSetMetaData, resultSet);
|
||||
|
||||
ResultSetRecordSet testSubject = new ResultSetRecordSet(resultSet, recordSchema, 10,0, useLogicalTypes);
|
||||
ResultSetRecordSet testSubject = new ResultSetRecordSet(resultSet, recordSchema, 10, 0, useLogicalTypes);
|
||||
RecordSchema actualSchema = testSubject.getSchema();
|
||||
|
||||
// THEN
|
||||
|
|
|
@ -184,13 +184,13 @@ public class TestDataTypeUtils {
|
|||
public void testConvertRecordMapToJavaMap() {
|
||||
assertNull(DataTypeUtils.convertRecordMapToJavaMap(null, null));
|
||||
assertNull(DataTypeUtils.convertRecordMapToJavaMap(null, RecordFieldType.MAP.getDataType()));
|
||||
Map<String,Object> resultMap = DataTypeUtils.convertRecordMapToJavaMap(new HashMap<>(), RecordFieldType.MAP.getDataType());
|
||||
Map<String, Object> resultMap = DataTypeUtils.convertRecordMapToJavaMap(new HashMap<>(), RecordFieldType.MAP.getDataType());
|
||||
assertNotNull(resultMap);
|
||||
assertTrue(resultMap.isEmpty());
|
||||
|
||||
int[] intArray = {3,2,1};
|
||||
int[] intArray = {3, 2, 1};
|
||||
|
||||
Map<String,Object> inputMap = new HashMap<String,Object>() {{
|
||||
Map<String, Object> inputMap = new HashMap<String, Object>() {{
|
||||
put("field1", "hello");
|
||||
put("field2", 1);
|
||||
put("field3", intArray);
|
||||
|
@ -250,7 +250,7 @@ public class TestDataTypeUtils {
|
|||
Object result = DataTypeUtils.convertType(expected, RecordFieldType.ARRAY.getDataType(), "uuid_test");
|
||||
assertTrue(result instanceof Byte[]);
|
||||
assertEquals( 16, ((Byte[]) result).length);
|
||||
Byte[] bytes = (Byte[])result;
|
||||
Byte[] bytes = (Byte[]) result;
|
||||
for (int x = 0; x < bytes.length; x++) {
|
||||
byte current = bytes[x];
|
||||
assertEquals(expected[x], current);
|
||||
|
@ -264,7 +264,7 @@ public class TestDataTypeUtils {
|
|||
String[] stringArray = {"Hello", "World!"};
|
||||
Object[] resultArray = DataTypeUtils.convertRecordArrayToJavaArray(stringArray, RecordFieldType.STRING.getDataType());
|
||||
assertNotNull(resultArray);
|
||||
for(Object o : resultArray) {
|
||||
for (Object o : resultArray) {
|
||||
assertTrue(o instanceof String);
|
||||
}
|
||||
}
|
||||
|
@ -292,14 +292,14 @@ public class TestDataTypeUtils {
|
|||
assertNotNull(resultObj);
|
||||
assertTrue(resultObj instanceof Object[]);
|
||||
Object[] resultArray = (Object[]) resultObj;
|
||||
for(Object o : resultArray) {
|
||||
for (Object o : resultArray) {
|
||||
assertTrue(o instanceof Map);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConvertRecordFieldToObjectWithNestedRecord() {
|
||||
final Record record = DataTypeUtils.toRecord(new LinkedHashMap<String, Object>(){{
|
||||
final Record record = DataTypeUtils.toRecord(new LinkedHashMap<String, Object>() {{
|
||||
put("firstName", "John");
|
||||
put("age", 30);
|
||||
put("addresses", new Object[] {"some string", DataTypeUtils.toRecord(Collections.singletonMap("address_1", "123 Fake Street"), "addresses")});
|
||||
|
@ -351,19 +351,19 @@ public class TestDataTypeUtils {
|
|||
final Map<String, Object> values = new HashMap<>();
|
||||
values.put("noDefault", "world");
|
||||
values.put("intField", 5);
|
||||
values.put("intArray", new Integer[] {3,2,1});
|
||||
values.put("objArray", new Object[] {3,"2","abc",1});
|
||||
values.put("noChoiceArray", new Object[] {"foo","BAR"});
|
||||
values.put("choiceArray", new Object[] {"foo",new Object[]{"bar","baz"}});
|
||||
values.put("intArray", new Integer[] {3, 2, 1});
|
||||
values.put("objArray", new Object[] {3, "2", "abc", 1});
|
||||
values.put("noChoiceArray", new Object[] {"foo", "BAR"});
|
||||
values.put("choiceArray", new Object[] {"foo", new Object[]{"bar", "baz"}});
|
||||
final Map<String, Object> complexValues = new HashMap<>();
|
||||
|
||||
final Map<String, Object> complexValueRecord1 = new HashMap<>();
|
||||
complexValueRecord1.put("a",new Integer[] {3,2,1});
|
||||
complexValueRecord1.put("b",new Integer[] {5,4,3});
|
||||
complexValueRecord1.put("a", new Integer[] {3, 2, 1});
|
||||
complexValueRecord1.put("b", new Integer[] {5, 4, 3});
|
||||
|
||||
final Map<String, Object> complexValueRecord2 = new HashMap<>();
|
||||
complexValueRecord2.put("a",new String[] {"hello","world!"});
|
||||
complexValueRecord2.put("b",new String[] {"5","4","3"});
|
||||
complexValueRecord2.put("a", new String[] {"hello", "world!"});
|
||||
complexValueRecord2.put("b", new String[] {"5", "4", "3"});
|
||||
|
||||
complexValues.put("complex1", DataTypeUtils.toRecord(complexValueRecord1, nestedRecordSchema, "complex1", StandardCharsets.UTF_8));
|
||||
complexValues.put("complex2", DataTypeUtils.toRecord(complexValueRecord2, nestedRecordSchema, "complex2", StandardCharsets.UTF_8));
|
||||
|
@ -373,25 +373,25 @@ public class TestDataTypeUtils {
|
|||
|
||||
Object o = DataTypeUtils.convertRecordFieldtoObject(inputRecord, RecordFieldType.RECORD.getRecordDataType(schema));
|
||||
assertTrue(o instanceof Map);
|
||||
final Map<String,Object> outputMap = (Map<String,Object>) o;
|
||||
final Map<String, Object> outputMap = (Map<String, Object>) o;
|
||||
assertEquals("hello", outputMap.get("defaultOfHello"));
|
||||
assertEquals("world", outputMap.get("noDefault"));
|
||||
o = outputMap.get("intField");
|
||||
assertEquals(5,o);
|
||||
assertEquals(5, o);
|
||||
o = outputMap.get("intArray");
|
||||
assertTrue(o instanceof Integer[]);
|
||||
final Integer[] intArray = (Integer[])o;
|
||||
final Integer[] intArray = (Integer[]) o;
|
||||
assertEquals(3, intArray.length);
|
||||
assertEquals((Integer)3, intArray[0]);
|
||||
assertEquals((Integer) 3, intArray[0]);
|
||||
o = outputMap.get("objArray");
|
||||
assertTrue(o instanceof Object[]);
|
||||
final Object[] objArray = (Object[])o;
|
||||
final Object[] objArray = (Object[]) o;
|
||||
assertEquals(4, objArray.length);
|
||||
assertEquals(3, objArray[0]);
|
||||
assertEquals("2", objArray[1]);
|
||||
o = outputMap.get("choiceArray");
|
||||
assertTrue(o instanceof Object[]);
|
||||
final Object[] choiceArray = (Object[])o;
|
||||
final Object[] choiceArray = (Object[]) o;
|
||||
assertEquals(2, choiceArray.length);
|
||||
assertEquals("foo", choiceArray[0]);
|
||||
assertTrue(choiceArray[1] instanceof Object[]);
|
||||
|
@ -401,25 +401,25 @@ public class TestDataTypeUtils {
|
|||
assertEquals("baz", strArray[1]);
|
||||
o = outputMap.get("complex");
|
||||
assertTrue(o instanceof Map);
|
||||
final Map<String,Object> nestedOutputMap = (Map<String,Object>)o;
|
||||
final Map<String, Object> nestedOutputMap = (Map<String, Object>) o;
|
||||
o = nestedOutputMap.get("complex1");
|
||||
assertTrue(o instanceof Map);
|
||||
final Map<String,Object> complex1 = (Map<String,Object>)o;
|
||||
final Map<String, Object> complex1 = (Map<String, Object>) o;
|
||||
o = complex1.get("a");
|
||||
assertTrue(o instanceof Integer[]);
|
||||
assertEquals((Integer)2, ((Integer[])o)[1]);
|
||||
assertEquals((Integer) 2, ((Integer[]) o)[1]);
|
||||
o = complex1.get("b");
|
||||
assertTrue(o instanceof Integer[]);
|
||||
assertEquals((Integer)3, ((Integer[])o)[2]);
|
||||
assertEquals((Integer) 3, ((Integer[]) o)[2]);
|
||||
o = nestedOutputMap.get("complex2");
|
||||
assertTrue(o instanceof Map);
|
||||
final Map<String,Object> complex2 = (Map<String,Object>)o;
|
||||
final Map<String, Object> complex2 = (Map<String, Object>) o;
|
||||
o = complex2.get("a");
|
||||
assertTrue(o instanceof String[]);
|
||||
assertEquals("hello", ((String[])o)[0]);
|
||||
assertEquals("hello", ((String[]) o)[0]);
|
||||
o = complex2.get("b");
|
||||
assertTrue(o instanceof String[]);
|
||||
assertEquals("4", ((String[])o)[1]);
|
||||
assertEquals("4", ((String[]) o)[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -436,7 +436,7 @@ public class TestDataTypeUtils {
|
|||
|
||||
@Test
|
||||
public void testStringToBytes() {
|
||||
Object bytes = DataTypeUtils.convertType("Hello", RecordFieldType.ARRAY.getArrayDataType(RecordFieldType.BYTE.getDataType()),null, StandardCharsets.UTF_8);
|
||||
Object bytes = DataTypeUtils.convertType("Hello", RecordFieldType.ARRAY.getArrayDataType(RecordFieldType.BYTE.getDataType()), null, StandardCharsets.UTF_8);
|
||||
assertTrue(bytes instanceof Byte[]);
|
||||
assertNotNull(bytes);
|
||||
Byte[] b = (Byte[]) bytes;
|
||||
|
@ -449,7 +449,7 @@ public class TestDataTypeUtils {
|
|||
|
||||
@Test
|
||||
public void testBytesToString() {
|
||||
Object s = DataTypeUtils.convertType("Hello".getBytes(StandardCharsets.UTF_16), RecordFieldType.STRING.getDataType(),null, StandardCharsets.UTF_16);
|
||||
Object s = DataTypeUtils.convertType("Hello".getBytes(StandardCharsets.UTF_16), RecordFieldType.STRING.getDataType(), null, StandardCharsets.UTF_16);
|
||||
assertNotNull(s);
|
||||
assertTrue(s instanceof String);
|
||||
assertEquals("Hello", s, "Conversion from byte[] to String failed");
|
||||
|
@ -457,7 +457,7 @@ public class TestDataTypeUtils {
|
|||
|
||||
@Test
|
||||
public void testBytesToBytes() {
|
||||
Object b = DataTypeUtils.convertType("Hello".getBytes(StandardCharsets.UTF_16), RecordFieldType.ARRAY.getArrayDataType(RecordFieldType.BYTE.getDataType()),null, StandardCharsets.UTF_16);
|
||||
Object b = DataTypeUtils.convertType("Hello".getBytes(StandardCharsets.UTF_16), RecordFieldType.ARRAY.getArrayDataType(RecordFieldType.BYTE.getDataType()), null, StandardCharsets.UTF_16);
|
||||
assertNotNull(b);
|
||||
assertTrue(b instanceof Byte[]);
|
||||
assertEquals((Object) "Hello".getBytes(StandardCharsets.UTF_16)[0], ((Byte[]) b)[0], "Conversion from byte[] to String failed at char 0");
|
||||
|
@ -611,7 +611,7 @@ public class TestDataTypeUtils {
|
|||
|
||||
@Test
|
||||
public void testIsCompatibleDataTypeMap() {
|
||||
Map<String,Object> testMap = new HashMap<>();
|
||||
Map<String, Object> testMap = new HashMap<>();
|
||||
testMap.put("Hello", "World");
|
||||
assertTrue(DataTypeUtils.isCompatibleDataType(testMap, RecordFieldType.RECORD.getDataType()));
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ public class TestDataTypeUtils {
|
|||
map.put("a", "Hello");
|
||||
map.put("b", "World");
|
||||
|
||||
RecordDataType expected = (RecordDataType)RecordFieldType.RECORD.getRecordDataType(new SimpleRecordSchema(Arrays.asList(
|
||||
RecordDataType expected = (RecordDataType) RecordFieldType.RECORD.getRecordDataType(new SimpleRecordSchema(Arrays.asList(
|
||||
new RecordField("a", RecordFieldType.STRING.getDataType()),
|
||||
new RecordField("b", RecordFieldType.STRING.getDataType())
|
||||
)));
|
||||
|
@ -804,7 +804,7 @@ public class TestDataTypeUtils {
|
|||
map.put(1, "Hello");
|
||||
map.put(2, "World");
|
||||
|
||||
RecordDataType expected = (RecordDataType)RecordFieldType.RECORD.getRecordDataType(new SimpleRecordSchema(Arrays.asList(
|
||||
RecordDataType expected = (RecordDataType) RecordFieldType.RECORD.getRecordDataType(new SimpleRecordSchema(Arrays.asList(
|
||||
new RecordField("1", RecordFieldType.STRING.getDataType()),
|
||||
new RecordField("2", RecordFieldType.STRING.getDataType())
|
||||
)));
|
||||
|
@ -1046,42 +1046,42 @@ public class TestDataTypeUtils {
|
|||
assertFalse(DataTypeUtils.isDoubleWithinFloatInterval(9));
|
||||
assertFalse(DataTypeUtils.isDoubleWithinFloatInterval(9.0F));
|
||||
assertFalse(DataTypeUtils.isDoubleWithinFloatInterval(Double.MAX_VALUE));
|
||||
assertFalse(DataTypeUtils.isDoubleWithinFloatInterval((double) -1 * Double.MAX_VALUE));
|
||||
assertFalse(DataTypeUtils.isDoubleWithinFloatInterval(-1 * Double.MAX_VALUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsFittingNumberType() {
|
||||
// Byte
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((byte) 9, RecordFieldType.BYTE));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType((short)9, RecordFieldType.BYTE));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType((short) 9, RecordFieldType.BYTE));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(9, RecordFieldType.BYTE));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(9L, RecordFieldType.BYTE));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(BigInteger.valueOf(9L), RecordFieldType.BYTE));
|
||||
|
||||
// Short
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((byte) 9, RecordFieldType.SHORT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((short)9, RecordFieldType.SHORT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((short) 9, RecordFieldType.SHORT));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(9, RecordFieldType.SHORT));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(9L, RecordFieldType.SHORT));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(BigInteger.valueOf(9L), RecordFieldType.SHORT));
|
||||
|
||||
// Integer
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((byte) 9, RecordFieldType.INT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((short)9, RecordFieldType.INT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((short) 9, RecordFieldType.INT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType(9, RecordFieldType.INT));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(9L, RecordFieldType.INT));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(BigInteger.valueOf(9L), RecordFieldType.INT));
|
||||
|
||||
// Long
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((byte) 9, RecordFieldType.LONG));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((short)9, RecordFieldType.LONG));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((short) 9, RecordFieldType.LONG));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType(9, RecordFieldType.LONG));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType(9L, RecordFieldType.LONG));
|
||||
assertFalse(DataTypeUtils.isFittingNumberType(BigInteger.valueOf(9L), RecordFieldType.LONG));
|
||||
|
||||
// Bigint
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((byte) 9, RecordFieldType.BIGINT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((short)9, RecordFieldType.BIGINT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType((short) 9, RecordFieldType.BIGINT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType(9, RecordFieldType.BIGINT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType(9L, RecordFieldType.BIGINT));
|
||||
assertTrue(DataTypeUtils.isFittingNumberType(BigInteger.valueOf(9L), RecordFieldType.BIGINT));
|
||||
|
@ -1103,7 +1103,7 @@ public class TestDataTypeUtils {
|
|||
int month = 1;
|
||||
int dayOfMonth = 25;
|
||||
|
||||
Date dateLocalTZ = new Date(ZonedDateTime.of(LocalDateTime.of(year, month, dayOfMonth,0,0,0), ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
Date dateLocalTZ = new Date(ZonedDateTime.of(LocalDateTime.of(year, month, dayOfMonth, 0, 0, 0), ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
|
||||
Date dateUTC = DataTypeUtils.convertDateToUTC(dateLocalTZ);
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ public class TestDataTypeUtils {
|
|||
@Test
|
||||
public void testConvertTypeStringToDateConfiguredSystemDefaultTimeZoneFormat() {
|
||||
final Object converted = DataTypeUtils.convertType(
|
||||
CUSTOM_MONTH_DAY_YEAR, RecordFieldType.DATE.getDataType(), Optional.of(CUSTOM_MONTH_DAY_YEAR_PATTERN), Optional.empty(), Optional.empty(),"date"
|
||||
CUSTOM_MONTH_DAY_YEAR, RecordFieldType.DATE.getDataType(), Optional.of(CUSTOM_MONTH_DAY_YEAR_PATTERN), Optional.empty(), Optional.empty(), "date"
|
||||
);
|
||||
assertTrue(converted instanceof java.sql.Date, "Converted value is not java.sql.Date");
|
||||
assertEquals(ISO_8601_YEAR_MONTH_DAY, converted.toString());
|
||||
|
|
|
@ -313,11 +313,11 @@ class TestMapRecord {
|
|||
|
||||
Record record = new MapRecord(fullSchema, values);
|
||||
|
||||
Map<String, Object> fullConversion = ((MapRecord)record).toMap(true);
|
||||
Map<String, Object> fullConversion = ((MapRecord) record).toMap(true);
|
||||
assertEquals(FOO_TEST_VAL, fullConversion.get("foo"));
|
||||
assertTrue(fullConversion.get("nested") instanceof Map);
|
||||
|
||||
Map<String, Object> nested = (Map<String, Object>)fullConversion.get("nested");
|
||||
Map<String, Object> nested = (Map<String, Object>) fullConversion.get("nested");
|
||||
assertEquals(1, nested.size());
|
||||
assertEquals(NESTED_RECORD_VALUE, nested.get("test"));
|
||||
|
||||
|
@ -326,7 +326,7 @@ class TestMapRecord {
|
|||
assertEquals(5, recordList.size());
|
||||
for (Object rec : recordList) {
|
||||
assertTrue(rec instanceof Map);
|
||||
Map<String, Object> map = (Map<String, Object>)rec;
|
||||
Map<String, Object> map = (Map<String, Object>) rec;
|
||||
assertEquals(1, map.size());
|
||||
assertEquals(NESTED_RECORD_VALUE, map.get("test"));
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public class TestSchemaRecordReaderWriter {
|
|||
final SchemaRecordReader reader = SchemaRecordReader.fromSchema(readSchema, new NoOpFieldCache());
|
||||
|
||||
// Read two records and verify the values.
|
||||
for (int i=0; i < 2; i++) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
final Record record = reader.readRecord(in);
|
||||
|
||||
assertNotNull(record);
|
||||
|
@ -219,13 +219,13 @@ public class TestSchemaRecordReaderWriter {
|
|||
final SchemaRecordReader reader = SchemaRecordReader.fromSchema(readSchema, new NoOpFieldCache());
|
||||
|
||||
// Read the records and verify the values.
|
||||
for (int i=0; i < 2; i++) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
final Record record = reader.readRecord(in);
|
||||
|
||||
assertNotNull(record);
|
||||
assertEquals(42, record.getFieldValue("int present"));
|
||||
assertTrue(MAX_ALLOWED_UTF_LENGTH - ((String)record.getFieldValue("string present")).getBytes("utf-8").length <= 3);
|
||||
assertEquals(32768, ((String)record.getFieldValue("string present")).length());
|
||||
assertTrue(MAX_ALLOWED_UTF_LENGTH - ((String) record.getFieldValue("string present")).getBytes("utf-8").length <= 3);
|
||||
assertEquals(32768, ((String) record.getFieldValue("string present")).length());
|
||||
}
|
||||
|
||||
// Ensure that there is no more data.
|
||||
|
|
|
@ -153,7 +153,7 @@ public class KerberosUserIT {
|
|||
// Since we set the lifetime to 15 seconds we should hit a relogin before 15 attempts
|
||||
|
||||
boolean performedRelogin = false;
|
||||
for (int i=0; i < 30; i++) {
|
||||
for (int i = 0; i < 30; i++) {
|
||||
Thread.sleep(1000);
|
||||
System.out.println("checkTGTAndRelogin #" + i);
|
||||
performedRelogin = user1.checkTGTAndRelogin();
|
||||
|
|
|
@ -52,7 +52,7 @@ public class StandardKeyStoreBuilder implements KeyStoreBuilder {
|
|||
|
||||
try {
|
||||
keyStore.load(inputStream, password);
|
||||
} catch (final IOException|NoSuchAlgorithmException|CertificateException e) {
|
||||
} catch (final IOException | NoSuchAlgorithmException | CertificateException e) {
|
||||
throw new BuilderConfigurationException("Key Store loading failed", e);
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ public class KeyStoreUtils {
|
|||
keyStore.load(keyStoreStream, keystorePassword);
|
||||
}
|
||||
return keyStore;
|
||||
} catch (final GeneralSecurityException|IOException e) {
|
||||
} catch (final GeneralSecurityException | IOException e) {
|
||||
throw new TlsException(String.format("Loading Secret Keystore [%s] Type [%s] Failed", keystorePath, keystoreTypeName), e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ public class HashService {
|
|||
final byte[] buffer = new byte[BUFFER_SIZE];
|
||||
int read = value.read(buffer);
|
||||
while (read != -1) {
|
||||
messageDigest.update(buffer, 0 , read);
|
||||
messageDigest.update(buffer, 0, read);
|
||||
read = value.read(buffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,13 +88,13 @@ public class KeyStoreUtilsTest {
|
|||
password,
|
||||
keyStoreType
|
||||
);
|
||||
final TlsConfiguration configuration = KeyStoreUtils.createTlsConfigAndNewKeystoreTruststore(requested, 1, new String[] { HOSTNAME });
|
||||
final TlsConfiguration configuration = KeyStoreUtils.createTlsConfigAndNewKeystoreTruststore(requested, 1, new String[] {HOSTNAME});
|
||||
final File keystoreFile = new File(configuration.getKeystorePath());
|
||||
assertTrue(keystoreFile.exists(), "Keystore File not found");
|
||||
keystoreFile.deleteOnExit();
|
||||
|
||||
final File truststoreFile = new File(configuration.getTruststorePath());
|
||||
assertTrue(truststoreFile.exists(),"Truststore File not found");
|
||||
assertTrue(truststoreFile.exists(), "Truststore File not found");
|
||||
truststoreFile.deleteOnExit();
|
||||
|
||||
assertEquals(KeystoreType.PKCS12, configuration.getKeystoreType(), "Keystore Type not matched");
|
||||
|
|
|
@ -637,7 +637,7 @@ public interface SiteToSiteClient extends Closeable {
|
|||
throw new IllegalStateException("Must specify either Port Name or Port Identifier to build Site-to-Site client");
|
||||
}
|
||||
|
||||
switch (transportProtocol){
|
||||
switch (transportProtocol) {
|
||||
case RAW:
|
||||
return new SocketClient(buildConfig());
|
||||
case HTTP:
|
||||
|
@ -717,7 +717,7 @@ public interface SiteToSiteClient extends Closeable {
|
|||
/**
|
||||
* @return the transport protocol to use, defaults to RAW
|
||||
*/
|
||||
public SiteToSiteTransportProtocol getTransportProtocol(){
|
||||
public SiteToSiteTransportProtocol getTransportProtocol() {
|
||||
return transportProtocol;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class HttpCommunicationsSession extends AbstractCommunicationsSession {
|
|||
protected String checksum;
|
||||
private String dataTransferUrl;
|
||||
|
||||
public HttpCommunicationsSession(){
|
||||
public HttpCommunicationsSession() {
|
||||
super();
|
||||
this.input = new HttpInput();
|
||||
this.output = new HttpOutput();
|
||||
|
|
|
@ -47,7 +47,7 @@ public class HttpClientTransaction extends AbstractTransaction {
|
|||
public void initialize(SiteToSiteRestApiClient apiUtil, String transactionUrl) throws IOException {
|
||||
this.transactionUrl = transactionUrl;
|
||||
this.apiClient = apiUtil;
|
||||
if(TransferDirection.RECEIVE.equals(direction)){
|
||||
if (TransferDirection.RECEIVE.equals(direction)) {
|
||||
dataAvailable = apiUtil.openConnectionForReceive(transactionUrl, peer);
|
||||
} else {
|
||||
apiUtil.openConnectionForSend(transactionUrl, peer);
|
||||
|
@ -59,12 +59,12 @@ public class HttpClientTransaction extends AbstractTransaction {
|
|||
HttpCommunicationsSession commSession = (HttpCommunicationsSession) peer.getCommunicationsSession();
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(bos);
|
||||
if(TransferDirection.RECEIVE.equals(direction)){
|
||||
switch (state){
|
||||
if (TransferDirection.RECEIVE.equals(direction)) {
|
||||
switch (state) {
|
||||
case TRANSACTION_STARTED:
|
||||
case DATA_EXCHANGED:
|
||||
logger.debug("{} {} readTransactionResponse. checksum={}", this, peer, commSession.getChecksum());
|
||||
if(StringUtils.isEmpty(commSession.getChecksum())){
|
||||
if (StringUtils.isEmpty(commSession.getChecksum())) {
|
||||
// We don't know if there's more data to receive, so just continue it.
|
||||
ResponseCode.CONTINUE_TRANSACTION.writeResponse(dos);
|
||||
} else {
|
||||
|
@ -76,7 +76,7 @@ public class HttpClientTransaction extends AbstractTransaction {
|
|||
TransactionResultEntity transactionResult
|
||||
= apiClient.commitReceivingFlowFiles(transactionUrl, ResponseCode.CONFIRM_TRANSACTION, commSession.getChecksum());
|
||||
ResponseCode responseCode = ResponseCode.fromCode(transactionResult.getResponseCode());
|
||||
if(responseCode.containsMessage()){
|
||||
if (responseCode.containsMessage()) {
|
||||
String message = transactionResult.getMessage();
|
||||
responseCode.writeResponse(dos, message == null ? "" : message);
|
||||
} else {
|
||||
|
@ -87,7 +87,7 @@ public class HttpClientTransaction extends AbstractTransaction {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
switch (state){
|
||||
switch (state) {
|
||||
case DATA_EXCHANGED:
|
||||
// Some flow files have been sent via stream, finish transferring.
|
||||
apiClient.finishTransferFlowFiles(commSession);
|
||||
|
@ -96,7 +96,7 @@ public class HttpClientTransaction extends AbstractTransaction {
|
|||
case TRANSACTION_CONFIRMED:
|
||||
TransactionResultEntity resultEntity = apiClient.commitTransferFlowFiles(transactionUrl, ResponseCode.CONFIRM_TRANSACTION);
|
||||
ResponseCode responseCode = ResponseCode.fromCode(resultEntity.getResponseCode());
|
||||
if(responseCode.containsMessage()){
|
||||
if (responseCode.containsMessage()) {
|
||||
responseCode.writeResponse(dos, resultEntity.getMessage());
|
||||
} else {
|
||||
responseCode.writeResponse(dos);
|
||||
|
@ -111,7 +111,7 @@ public class HttpClientTransaction extends AbstractTransaction {
|
|||
@Override
|
||||
protected void writeTransactionResponse(ResponseCode response, String explanation, boolean flush) throws IOException {
|
||||
HttpCommunicationsSession commSession = (HttpCommunicationsSession) peer.getCommunicationsSession();
|
||||
if(TransferDirection.RECEIVE.equals(direction)){
|
||||
if (TransferDirection.RECEIVE.equals(direction)) {
|
||||
switch (response) {
|
||||
case CONFIRM_TRANSACTION:
|
||||
logger.debug("{} Confirming transaction. checksum={}", this, explanation);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class SocketClientTransaction extends AbstractTransaction {
|
|||
|
||||
@Override
|
||||
protected void writeTransactionResponse(ResponseCode response, String explanation, boolean flush) throws IOException {
|
||||
if(explanation == null){
|
||||
if (explanation == null) {
|
||||
response.writeResponse(dos, flush);
|
||||
} else {
|
||||
response.writeResponse(dos, explanation, flush);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue