use of org.jetbrains.annotations.VisibleForTesting in project activej by activej.
the class CubeUplinkMySql method fetchPositionDiffs.
@VisibleForTesting
Map<String, LogPositionDiff> fetchPositionDiffs(Connection connection, long from, long to) throws SQLException {
Map<String, LogPositionDiff> positions = new HashMap<>();
try (PreparedStatement ps = connection.prepareStatement(sql("" + "SELECT p.`partition_id`, p.`filename`, p.`remainder`, p.`position`, g.`to` " + "FROM (SELECT `partition_id`, MAX(`revision_id`) AS `max_revision`, `revision_id`>? as `to`" + " FROM {position}" + " WHERE `revision_id`<=?" + " GROUP BY `partition_id`, `to`) g " + "LEFT JOIN" + " {position} p " + "ON p.`partition_id` = g.`partition_id` " + "AND p.`revision_id` = g.`max_revision` " + "ORDER BY p.`partition_id`, `to`"))) {
ps.setLong(1, from);
ps.setLong(2, to);
ResultSet resultSet = ps.executeQuery();
LogPosition[] fromTo = new LogPosition[2];
String currentPartition = null;
while (resultSet.next()) {
String partition = resultSet.getString(1);
if (!partition.equals(currentPartition)) {
fromTo[0] = null;
fromTo[1] = null;
}
currentPartition = partition;
String filename = resultSet.getString(2);
int remainder = resultSet.getInt(3);
long position = resultSet.getLong(4);
boolean isTo = resultSet.getBoolean(5);
LogFile logFile = new LogFile(filename, remainder);
LogPosition logPosition = LogPosition.create(logFile, position);
if (isTo) {
if (fromTo[0] == null) {
fromTo[0] = LogPosition.initial();
}
fromTo[1] = logPosition;
} else {
fromTo[0] = logPosition;
fromTo[1] = null;
continue;
}
LogPositionDiff logPositionDiff = new LogPositionDiff(fromTo[0], fromTo[1]);
positions.put(partition, logPositionDiff);
}
}
return positions;
}
use of org.jetbrains.annotations.VisibleForTesting in project jetbrains-plugin by codiga.
the class PythonDependency method getDependenciesFromInputStream.
@VisibleForTesting
@Override
public List<Dependency> getDependenciesFromInputStream(InputStream inputStream) {
List<Dependency> result = new ArrayList<>();
String pattern = "^([a-zA-Z0-9\\-]+)";
Pattern r = Pattern.compile(pattern);
try {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
Matcher m = r.matcher(line);
if (m.find()) {
result.add(new Dependency(m.group(0), Optional.empty()));
}
}
return result;
} catch (IOException e) {
LOGGER.info("PythonDependency - getDependenciesFromInputStream - error when parsing the file");
return ImmutableList.of();
}
}
use of org.jetbrains.annotations.VisibleForTesting in project jetbrains-plugin by codiga.
the class RubyDependency method getDependenciesFromInputStream.
@VisibleForTesting
@Override
public List<Dependency> getDependenciesFromInputStream(InputStream inputStream) {
List<Dependency> result = new ArrayList<>();
String pattern = "^\\s*gem\\s+[\\'|\\\"]([a-zA-Z0-9\\-]+)[\\'|\\\"]";
Pattern r = Pattern.compile(pattern);
try {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8");
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line;
while ((line = bufferedReader.readLine()) != null) {
System.out.println(line);
// if there is a comment, do not use
if (line.contains("#")) {
continue;
}
Matcher m = r.matcher(line);
if (m.find()) {
result.add(new Dependency(m.group(1), Optional.empty()));
}
}
return result;
} catch (IOException e) {
LOGGER.info("PythonDependency - getDependenciesFromInputStream - error when parsing the file");
return ImmutableList.of();
}
}
use of org.jetbrains.annotations.VisibleForTesting in project midpoint by Evolveum.
the class SimpleReportReader method createForLocalReportData.
@VisibleForTesting
@NotNull
public static SimpleReportReader createForLocalReportData(@NotNull String reportDataOid, @NotNull List<String> columns, @NotNull CommonTaskBeans beans, @NotNull OperationResult result) throws IOException, SchemaException, ObjectNotFoundException {
var reportDataObject = beans.repositoryService.getObject(ReportDataType.class, reportDataOid, null, result);
String filePath = MiscUtil.requireNonNull(reportDataObject.asObjectable().getFilePath(), () -> "No file in " + reportDataObject);
return createFor(new FileInputStream(filePath), columns);
}
use of org.jetbrains.annotations.VisibleForTesting in project midpoint by Evolveum.
the class ModelImplUtils method determineObjectDefinition.
@VisibleForTesting
public static ResourceObjectDefinition determineObjectDefinition(ResourceSchema refinedSchema, Task task) throws SchemaException {
QName objectclass = getTaskExtensionPropertyValue(task, SchemaConstants.MODEL_EXTENSION_OBJECTCLASS);
ShadowKindType kind = getTaskExtensionPropertyValue(task, SchemaConstants.MODEL_EXTENSION_KIND);
String intent = getTaskExtensionPropertyValue(task, SchemaConstants.MODEL_EXTENSION_INTENT);
return determineObjectClassInternal(refinedSchema, objectclass, kind, intent, task);
}
Aggregations