Skip to content
Permalink
Browse files
Optimize imports & code formatted for TC Bot packages
  • Loading branch information
dspavlov committed Feb 18, 2019
1 parent 1c56569 commit 5b8ebdd8979efbd4d66f2d963c4007c3832c1290
Showing 18 changed files with 165 additions and 187 deletions.
@@ -17,6 +17,9 @@

package org.apache.ignite.ci.tcbot.builds;

import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import org.apache.ignite.ci.analysis.MultBuildRunCtx;
import org.apache.ignite.ci.tcbot.chain.BuildChainProcessor;
import org.apache.ignite.ci.teamcity.ignited.IStringCompactor;
@@ -27,10 +30,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;

public class CompareBuildsService {
/** */
private static final Logger logger = LoggerFactory.getLogger(CompareBuildsService.class);
@@ -45,15 +44,15 @@ public class CompareBuildsService {
* @param prov Credentials provider.
* @return List of build tests.
*/
public List<String> tests0(String srvId, Integer buildId, ICredentialsProv prov ) {
public List<String> tests0(String srvId, Integer buildId, ICredentialsProv prov) {
ITeamcityIgnited srv = tcIgnitedProv.server(srvId, prov);

return tests0(srv, buildId, bcp);
}

/** */
private List<String> tests0(ITeamcityIgnited tcIgnited,
Integer buildId, BuildChainProcessor bcp) {
Integer buildId, BuildChainProcessor bcp) {
List<String> tests = new ArrayList<>();

FatBuildCompacted fatBuild = tcIgnited.getFatBuild(buildId);
@@ -80,9 +79,9 @@ private List<String> tests0(ITeamcityIgnited tcIgnited,
return tests;
}


/**
* Get rid from suite name.
*
* @param testFullName Test full name.
* @return Test name.
*/
@@ -77,8 +77,8 @@ public class BuildChainProcessor {
@Inject private IStringCompactor compactor;

/**
* Collects data about all long-running tests (run time more than one minute) across all suites in RunAll chain
* in master branch.
* Collects data about all long-running tests (run time more than one minute) across all suites in RunAll chain in
* master branch.
*
* @param teamcityIgnited interface to TC bot database.
* @param entryPoints
@@ -278,7 +278,7 @@ public Future<FatBuildCompacted> getOrLoadBuild(Integer id, SyncMode mode,
* @return Full context.
*/
public SingleBuildRunCtx loadChanges(@Nonnull FatBuildCompacted buildCompacted,
ITeamcityIgnited tcIgnited) {
ITeamcityIgnited tcIgnited) {
SingleBuildRunCtx ctx = new SingleBuildRunCtx(buildCompacted, compactor);

ctx.setChanges(tcIgnited.getAllChanges(buildCompacted.changes()));
@@ -299,8 +299,8 @@ protected List<Future<FatBuildCompacted>> replaceWithRecent(List<FatBuildCompact
return completed(builds);

Optional<FatBuildCompacted> maxIdBuildOpt = builds.stream()
.filter(b -> b.branchName() >= 0)
.max(Comparator.comparing(BuildRefCompacted::id));
.filter(b -> b.branchName() >= 0)
.max(Comparator.comparing(BuildRefCompacted::id));
if (!maxIdBuildOpt.isPresent())
return completed(builds);

@@ -341,18 +341,18 @@ protected void fillBuildCounts(MultBuildRunCtx outCtx,
final List<BuildRefCompacted> runAllBuilds = teamcityIgnited.getAllBuildsCompacted(outCtx.buildTypeId(), outCtx.branchName());

long cntRunning = runAllBuilds
.stream()
.filter(r -> r.isNotCancelled(compactor))
.filter(r -> r.isRunning(compactor)).count();
.stream()
.filter(r -> r.isNotCancelled(compactor))
.filter(r -> r.isRunning(compactor)).count();

outCtx.setRunningBuildCount((int) cntRunning);
outCtx.setRunningBuildCount((int)cntRunning);

long cntQueued = runAllBuilds
.stream()
.filter(r -> r.isNotCancelled(compactor))
.filter(r -> r.isQueued(compactor)).count();
long cntQueued = runAllBuilds
.stream()
.filter(r -> r.isNotCancelled(compactor))
.filter(r -> r.isQueued(compactor)).count();

outCtx.setQueuedBuildCount((int) cntQueued);
outCtx.setQueuedBuildCount((int)cntQueued);
}
}

@@ -362,7 +362,7 @@ protected void analyzeTests(MultBuildRunCtx outCtx, IAnalyticsEnabledTeamcity te
ProcessLogsMode procLog) {
for (SingleBuildRunCtx ctx : outCtx.getBuilds()) {
if ((procLog == ProcessLogsMode.SUITE_NOT_COMPLETE && ctx.hasSuiteIncompleteFailure())
|| procLog == ProcessLogsMode.ALL)
|| procLog == ProcessLogsMode.ALL)
ctx.setLogCheckResFut(teamcity.analyzeBuildLog(ctx.buildId(), ctx));
}
}
@@ -399,7 +399,6 @@ public Future<FatBuildCompacted> loadBuildAsync(Integer id, SyncMode mode, ITeam
return tcUpdatePool.getService().submit(() -> teamcityIgnited.getFatBuild(id, mode));
}


private List<Future<FatBuildCompacted>> completed(List<FatBuildCompacted> builds) {
return builds.stream().map(Futures::immediateFuture).collect(Collectors.toList());
}
@@ -186,8 +186,8 @@ else if (FullQueryParams.CHAIN.equals(act))
return getBlockersSuitesStatuses(buildTypeId, branchForTc, srvId, prov, SyncMode.RELOAD_QUEUED);
}


@Nullable public List<SuiteCurrentStatus> getBlockersSuitesStatuses(String buildTypeId, String branchForTc, String srvId,
@Nullable
public List<SuiteCurrentStatus> getBlockersSuitesStatuses(String buildTypeId, String branchForTc, String srvId,
ICredentialsProv prov, SyncMode queued) {
List<SuiteCurrentStatus> res = new ArrayList<>();

@@ -20,7 +20,6 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import javax.inject.Inject;

import org.apache.ignite.ci.IAnalyticsEnabledTeamcity;
import org.apache.ignite.ci.analysis.FullChainRunCtx;
import org.apache.ignite.ci.analysis.mode.LatestRebuildMode;
@@ -133,7 +133,7 @@ public void setValue(String str) {
flag + ")");
}

public static byte[] zipBytes(byte[] uncompressed ) throws IOException {
public static byte[] zipBytes(byte[] uncompressed) throws IOException {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
try (final GZIPOutputStream gzipOutputStream = new GZIPOutputStream(out)) {
gzipOutputStream.write(uncompressed);
@@ -17,11 +17,14 @@

package org.apache.ignite.ci.tcbot.conf;

import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;

import org.apache.ignite.ci.conf.BranchTracked;
import org.apache.ignite.ci.conf.ChainAtServer;

@@ -17,9 +17,8 @@
package org.apache.ignite.ci.tcbot.conf;

import com.google.common.base.Strings;
import org.apache.ignite.ci.HelperConfig;

import java.util.Properties;
import org.apache.ignite.ci.HelperConfig;

/**
*
@@ -39,7 +38,6 @@ public class GitHubConfig implements IGitHubConfig {

private Properties props;


public GitHubConfig() {
}

@@ -54,7 +54,6 @@ public default boolean isJiraTokenAvailable() {
return !Strings.isNullOrEmpty(decodedHttpAuthToken());
}


public default String restApiUrl() {
String jiraUrl = getUrl();

@@ -22,6 +22,7 @@
import org.apache.ignite.ci.HelperConfig;
import org.apache.ignite.ci.conf.PasswordEncoder;
import org.apache.ignite.ci.jira.pure.Fields;
import org.apache.ignite.ci.jira.pure.Ticket;
import org.jetbrains.annotations.Nullable;

import static com.google.common.base.Strings.isNullOrEmpty;
@@ -39,23 +40,17 @@ public class JiraServerConfig implements IJiraServerConfig {
private String projectCode;

/**
* Branch number prefix. Optional, if not present {@link #projectCode}-NNNNN is searched.
* But if branch has different enumeration, this prefix will be searched instead.
* If specified, that meant tickets maching branches have another identification.
* Branch number prefix. Optional, if not present {@link #projectCode}-NNNNN is searched.<br>
* But if branch has different enumeration, this prefix will be searched instead.<br>
* If specified, that meant tickets maching branches have another identification.<br>
* For exaple some ticket having ID {@link #projectCode}-N1 will be commented, but a branch will be identified using
* {@link #branchNumPrefix}N2 with another number.
* {@link #branchNumPrefix}N2 with another number.<br><br>
*
* Search of branches will be performed using data in JIRA ticket fields for
* {@link #projectCode}-N1, fields are listed in {@link #branchNumPrefixSearchFields}.
* {@link #projectCode}-N1, fields are listed in {@link Ticket} class.
*/
private String branchNumPrefix;

/**
* Branch ticket template search fields, list of JIRA fields IDs to be checked for finding out branch.
* Available fields are field names from {@link Fields} class.
*/
private ArrayList<String> branchNumPrefixSearchFields;

private Properties props;

/**
@@ -109,7 +104,7 @@ public JiraServerConfig code(String code) {

/** {@inheritDoc} */
@Override public String projectCodeForVisa() {
if(Strings.isNullOrEmpty(projectCode) && props!=null) {
if (Strings.isNullOrEmpty(projectCode) && props != null) {
String ticketPref = props.getProperty(HelperConfig.JIRA_TICKET_TEMPLATE, "IGNITE-");

return ticketPref.replaceAll("-", "");
@@ -51,16 +51,16 @@ public class LocalFilesBasedConfig implements ITcBotConfig {
@Override public IJiraServerConfig getJiraConfig(String srvCode) {
return getTrackedBranches().getJiraConfig(srvCode)
.orElseGet(() -> new JiraServerConfig()
.code(srvCode)
.properties(loadOldAuthProps(srvCode)));
.code(srvCode)
.properties(loadOldAuthProps(srvCode)));
}

@Override
public IGitHubConfig getGitConfig(String srvCode) {
return getTrackedBranches().getGitHubConfig(srvCode)
.orElseGet(() -> new GitHubConfig()
.code(srvCode)
.properties(loadOldAuthProps(srvCode)));
.orElseGet(() -> new GitHubConfig()
.code(srvCode)
.properties(loadOldAuthProps(srvCode)));
}

/** {@inheritDoc} */
@@ -70,7 +70,6 @@ public IGitHubConfig getGitConfig(String srvCode) {
return Strings.isNullOrEmpty(srvCode) ? ITcBotConfig.DEFAULT_SERVER_CODE : srvCode;
}


private Properties loadOldAuthProps(String srvCode) {
File workDir = HelperConfig.resolveWorkDir();

@@ -26,7 +26,6 @@ public interface IIssuesStorage {
* Determines if the storage contains an entry for the specified issue key.
*
* @param issueKey Issue to be checked.
*
* @return true if issue
*/
public boolean containsIssueKey(IssueKey issueKey);

0 comments on commit 5b8ebdd

Please sign in to comment.