aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-23 12:00:04 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-23 12:00:04 +0100
commitafbfd905b8f5326d149ba7fdfd784af50d85e5ee (patch)
tree7ebdb883ce69d697af278780bdf67362ce164c2d
parenta057cf0cb5b855d1fedd58d702bd06bb22e938f5 (diff)
downloadesper-testing-afbfd905b8f5326d149ba7fdfd784af50d85e5ee.tar.gz
esper-testing-afbfd905b8f5326d149ba7fdfd784af50d85e5ee.tar.bz2
esper-testing-afbfd905b8f5326d149ba7fdfd784af50d85e5ee.tar.xz
esper-testing-afbfd905b8f5326d149ba7fdfd784af50d85e5ee.zip
o Storing the file file reference on the jenkins build and job.
-rw-r--r--README.md4
-rw-r--r--src/main/java/io/trygvis/esper/testing/core/db/FileDao.java3
-rw-r--r--src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildDto.java4
-rw-r--r--src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java19
-rw-r--r--src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java7
-rw-r--r--src/main/resources/ddl-jenkins.sql4
-rw-r--r--src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java10
7 files changed, 36 insertions, 15 deletions
diff --git a/README.md b/README.md
index 15e1236..584d730 100644
--- a/README.md
+++ b/README.md
@@ -30,3 +30,7 @@ Product P has increased the number of tests the last N (commits|days).
Level 1: 3 programmers
Level 2: 4 programmers
Level 3: 5 programmers
+
+# BF3 Nomenclature
+
+Two types of "awards": "ribbons" and "medals". A medal is given for repeatedly awarded a ribbon.
diff --git a/src/main/java/io/trygvis/esper/testing/core/db/FileDao.java b/src/main/java/io/trygvis/esper/testing/core/db/FileDao.java
index 0878f63..c418970 100644
--- a/src/main/java/io/trygvis/esper/testing/core/db/FileDao.java
+++ b/src/main/java/io/trygvis/esper/testing/core/db/FileDao.java
@@ -14,7 +14,7 @@ public class FileDao {
this.c = c;
}
- public void store(URI url, String contentType, byte[] data) throws SQLException {
+ public UUID store(URI url, String contentType, byte[] data) throws SQLException {
try (PreparedStatement s = c.prepareStatement("INSERT INTO file(uuid, created_date, url, content_type, data) VALUES(?, ?, ?, ?, ?)")) {
UUID uuid = UUID.randomUUID();
int i = 1;
@@ -24,6 +24,7 @@ public class FileDao {
s.setString(i++, contentType);
s.setBinaryStream(i, new ByteArrayInputStream(data), data.length);
s.executeUpdate();
+ return uuid;
}
}
}
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildDto.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildDto.java
index 41d90ae..5c7249f 100644
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildDto.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsBuildDto.java
@@ -8,6 +8,7 @@ import java.util.*;
public class JenkinsBuildDto extends AbstractEntity {
public final UUID job;
+ public final UUID file;
public final String entryId;
public final URI url;
public final String result;
@@ -16,9 +17,10 @@ public class JenkinsBuildDto extends AbstractEntity {
public final DateTime timestamp;
public final UUID[] users;
- public JenkinsBuildDto(UUID uuid, DateTime createdDate, UUID job, String entryId, URI url, String result, int number, int duration, DateTime timestamp, UUID[] users) {
+ public JenkinsBuildDto(UUID uuid, DateTime createdDate, UUID job, UUID file, String entryId, URI url, String result, int number, int duration, DateTime timestamp, UUID[] users) {
super(uuid, createdDate);
this.job = job;
+ this.file = file;
this.entryId = entryId;
this.url = url;
this.result = result;
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
index a31c6a0..8d32dbe 100644
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
@@ -20,9 +20,7 @@ public class JenkinsDao {
public static final String JENKINS_SERVER = "uuid, created_date, url, enabled";
- public static final String JENKINS_JOB = "uuid, created_date, server, url, job_type, display_name";
-
- public static final String JENKINS_BUILD = "uuid, created_date, job, entry_id, url, result, number, duration, timestamp, users";
+ public static final String JENKINS_JOB = "uuid, created_date, server, file, url, job_type, display_name";
public static final String JENKINS_USER = "uuid, created_date, server, absolute_url";
@@ -67,6 +65,8 @@ public class JenkinsDao {
return list;
}
+ public static final String JENKINS_BUILD = "uuid, created_date, job, file, entry_id, url, result, number, duration, timestamp, users";
+
public static final SqlF<ResultSet, JenkinsBuildDto> jenkinsBuild = new SqlF<ResultSet, JenkinsBuildDto>() {
public JenkinsBuildDto apply(ResultSet rs) throws SQLException {
int i = 1;
@@ -74,6 +74,7 @@ public class JenkinsDao {
UUID.fromString(rs.getString(i++)),
new DateTime(rs.getTimestamp(i++).getTime()),
UUID.fromString(rs.getString(i++)),
+ UUID.fromString(rs.getString(i++)),
rs.getString(i++),
URI.create(rs.getString(i++)),
rs.getString(i++),
@@ -143,13 +144,14 @@ public class JenkinsDao {
}
}
- public UUID insertJob(UUID server, URI url, JenkinsJobXml.JenkinsJobType type, Option<String> displayName) throws SQLException {
- try (PreparedStatement s = c.prepareStatement("INSERT INTO jenkins_job(" + JENKINS_JOB + ") VALUES(?, ?, ?, ?, ?, ?)")) {
+ public UUID insertJob(UUID server, UUID file, URI url, JenkinsJobXml.JenkinsJobType type, Option<String> displayName) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("INSERT INTO jenkins_job(" + JENKINS_JOB + ") VALUES(?, ?, ?, ?, ?, ?, ?)")) {
UUID uuid = UUID.randomUUID();
int i = 1;
s.setString(i++, uuid.toString());
s.setTimestamp(i++, new Timestamp(currentTimeMillis()));
s.setString(i++, server.toString());
+ s.setString(i++, file.toString());
s.setString(i++, url.toASCIIString());
s.setString(i++, type.name());
s.setString(i, displayName.toNull());
@@ -167,13 +169,14 @@ public class JenkinsDao {
}
}
- public UUID insertBuild(UUID server, String entryId, URI url, String result, int number, int duration, long timestamp, UUID[] users) throws SQLException {
- try (PreparedStatement s = c.prepareStatement("INSERT INTO jenkins_build(" + JENKINS_BUILD + ") VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
+ public UUID insertBuild(UUID job, UUID file, String entryId, URI url, String result, int number, int duration, long timestamp, UUID[] users) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("INSERT INTO jenkins_build(" + JENKINS_BUILD + ") VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
UUID uuid = UUID.randomUUID();
int i = 1;
s.setString(i++, uuid.toString());
s.setTimestamp(i++, new Timestamp(currentTimeMillis()));
- s.setString(i++, server.toString());
+ s.setString(i++, job.toString());
+ s.setString(i++, file.toString());
s.setString(i++, entryId);
s.setString(i++, url.toASCIIString());
s.setString(i++, result);
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java
index 32728a6..c34f422 100644
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java
@@ -76,7 +76,7 @@ public class JenkinsServerActor implements TransactionalActor {
continue;
}
- fileDao.store(buildUrl, "application/xml", buildXmlOption.some()._2());
+ UUID buildXmlFile = fileDao.store(buildUrl, "application/xml", buildXmlOption.some()._2());
String result = build.result.some();
@@ -137,11 +137,11 @@ public class JenkinsServerActor implements TransactionalActor {
continue;
}
- fileDao.store(uri, "application/xml", jobXmlOption.some()._2());
+ UUID jobXmlFile = fileDao.store(uri, "application/xml", jobXmlOption.some()._2());
JenkinsJobXml xml = jobXmlOption.some()._1();
- job = dao.insertJob(server.uuid, xml.url, xml.type, xml.displayName);
+ job = dao.insertJob(server.uuid, jobXmlFile, xml.url, xml.type, xml.displayName);
logger.info("New job: {}, uuid={}", xml.displayName.orSome(xml.url.toASCIIString()), job);
}
@@ -150,6 +150,7 @@ public class JenkinsServerActor implements TransactionalActor {
UUID uuid = dao.insertBuild(
job,
+ buildXmlFile,
entry.id,
build.url,
result,
diff --git a/src/main/resources/ddl-jenkins.sql b/src/main/resources/ddl-jenkins.sql
index 2a57ad6..c75f836 100644
--- a/src/main/resources/ddl-jenkins.sql
+++ b/src/main/resources/ddl-jenkins.sql
@@ -21,12 +21,14 @@ CREATE TABLE jenkins_job (
server CHAR(36) NOT NULL,
+ file CHAR(36) NOT NULL,
url VARCHAR(1000) NOT NULL,
job_type VARCHAR(100) NOT NULL,
display_name VARCHAR(100),
CONSTRAINT pk_jenkins_job PRIMARY KEY (UUID),
CONSTRAINT fk_jenkins_job__server FOREIGN KEY (server) REFERENCES jenkins_server (uuid),
+ CONSTRAINT fk_jenkins_job__file FOREIGN KEY (file) REFERENCES file (uuid),
CONSTRAINT uq_jenkins_job__url UNIQUE (url)
);
@@ -39,6 +41,7 @@ CREATE TABLE jenkins_build (
job CHAR(36) NOT NULL,
+ file CHAR(36) NOT NULL,
entry_id VARCHAR(1000) NOT NULL,
url VARCHAR(1000) NOT NULL,
result VARCHAR(100) NOT NULL,
@@ -49,6 +52,7 @@ CREATE TABLE jenkins_build (
CONSTRAINT pk_jenkins_build PRIMARY KEY (UUID),
CONSTRAINT fk_jenkins_build__job FOREIGN KEY (job) REFERENCES jenkins_job (uuid),
+ CONSTRAINT fk_jenkins_build__file FOREIGN KEY (file) REFERENCES file (uuid),
CONSTRAINT uq_jenkins_build__id UNIQUE (entry_id),
CONSTRAINT uq_jenkins_build__seq UNIQUE (seq)
);
diff --git a/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java b/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java
index f03086b..a8f8ce7 100644
--- a/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java
+++ b/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.UUID;
import fj.*;
+import io.trygvis.esper.testing.core.db.*;
import org.apache.abdera.Abdera;
import org.codehaus.httpcache4j.cache.HTTPCache;
@@ -35,6 +36,7 @@ public class CreateMissingMavenModuleJobsApp {
ResultSet rs = s.executeQuery();
JenkinsDao dao = new JenkinsDao(c);
+ FileDao fileDao = new FileDao(c);
List<JenkinsJobDto> jobs = dao.toJobList(rs);
@@ -49,7 +51,9 @@ public class CreateMissingMavenModuleJobsApp {
URI url = URI.create(u);
- Option<P2<JenkinsJobXml,byte[]>> xmlOption = client.fetchJob(apiXml(url));
+ URI uri = apiXml(url);
+
+ Option<P2<JenkinsJobXml,byte[]>> xmlOption = client.fetchJob(uri);
if(xmlOption.isNone()) {
System.out.println("None");
@@ -63,7 +67,9 @@ public class CreateMissingMavenModuleJobsApp {
continue;
}
- UUID uuid = dao.insertJob(jobDto.server, url, jobXml.type, jobXml.displayName);
+ UUID file = fileDao.store(uri, "application/xml", xmlOption.some()._2());
+
+ UUID uuid = dao.insertJob(jobDto.server, file, url, jobXml.type, jobXml.displayName);
System.out.println("New job: " + uuid);
}