r308 - in branches/jredmine-1.x/jredmine-maven-plugin/src: main/java/org/nuiton/jredmine/plugin main/java/org/nuiton/jredmine/plugin/announcement test/java/org/nuiton/jredmine test/java/org/nuiton/jredmine/plugin test/java/org/nuiton/jredmine/plugin/announcement test/java/org/nuiton/jredmine/plugin/report test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest
Author: tchemit Date: 2012-07-15 21:09:51 +0200 (Sun, 15 Jul 2012) New Revision: 308 Url: http://nuiton.org/repositories/revision/jredmine/308 Log: refs #937: Maven test utilise les properties de test de la distribution (improve tests design) fixes #2189: Improve RedmineService design (apply api changes) clean mojos clean mojo test poms Added: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineAnonymousFixtureClassRule.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineLogguedFixtureClassRule.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractAnonymousRedmineMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractLogguedRedmineMojoTest.java Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/LoginMojo.java branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineFixtures.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractRedmineMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/DisplayDataMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/GenerateChangesMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/NextVersionMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/PublishNewsMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/UpdateVersionMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/announcement/GenerateEmailAnnouncementMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/announcement/GenerateNewsAnnouncementMojoTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReportTest.java branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest/generateEmailAnnouncement.xml branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest/skipGenerateEmailAnnouncement.xml branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest/generateNewsAnnouncement.xml branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest/skipGenerateNewsAnnouncement.xml Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/AbstractRedmineMojo.java 2012-07-15 19:09:51 UTC (rev 308) @@ -30,9 +30,8 @@ import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.jredmine.RedmineService; -import org.nuiton.jredmine.RedmineServiceImplementor; +import org.nuiton.jredmine.RedmineServiceConfiguration; import org.nuiton.plugin.AbstractPlugin; import java.net.URL; @@ -47,7 +46,7 @@ * @requiresProject true * @since 1.0.0 */ -public abstract class AbstractRedmineMojo extends AbstractPlugin implements RestClientConfiguration { +public abstract class AbstractRedmineMojo extends AbstractPlugin implements RedmineServiceConfiguration { public static final String REDMINE_SYSTEM = "redmine"; @@ -194,7 +193,7 @@ try { - ((RedmineServiceImplementor) service).init(this); + service.init(this); serviceInit = true; } catch (Exception e) { if (isSafe()) { @@ -204,44 +203,6 @@ initOk = false; getLog().error("could not init Redmine service [" + getRestUrl() + "] with user '" + getRestUsername() + "'", e); } - -// // check project exists -// -// if (requireProject) { -// boolean r = initReleaseProject(); -// if (!r) { -// if (isSafe()) { -// throw new MojoExecutionException("the project '" + projectId + "' could not be retrieve from redmine server."); -// } -// initOk = false; -// return; -// } -// } -// -// // check user exists -// -// if (requireUser) { -// boolean r = initReleaseUser(); -// if (!r) { -// if (isSafe()) { -// throw new MojoExecutionException("the user '" + username + "' could not be retrieve from redmine server."); -// } -// initOk = false; -// return; -// } -// } -// -// // check version exists -// -// if (requireVersion) { -// boolean r = initReleaseVersion(); -// if (!r) { -// if (isSafe()) { -// throw new MojoExecutionException("the version '" + versionId + "' could not be retrieve from redmine server."); -// } -// initOk = false; -// } -// } } @Override @@ -260,21 +221,6 @@ getLog().error("could not init Redmine service [" + getRestUrl() + "] with user '" + getRestUsername() + "'"); return false; } -// -// if (requireProject && releaseProject == null) { -// -// getLog().error("the project '" + projectId + "' could not be retrieve from redmine server, goal is skip"); -// return false; -// } -// if (requireUser && releaseUser == null) { -// getLog().error("the user '" + username + "' could not be retrieve from redmine server, goal is skip"); -// return false; -// } -// -// if (requireVersion && releaseVersion == null) { -// getLog().error("the version '" + versionId + "' could not be retrieve from redmine server, goal is skip"); -// return false; -// } return true; } @@ -374,85 +320,14 @@ /// Others /////////////////////////////////////////////////////////////////////////// -// protected boolean initReleaseProject() throws MojoExecutionException { -// -// if (projectId == null || projectId.trim().isEmpty()) { -// throw new MojoExecutionException("required a projectId parameter"); -// } -// try { -// Project p = service.getProject(projectId); -// -// if (p == null) { -// -// return false; -// } -// -// releaseProject = p; -// return true; -// } catch (RedmineServiceException e) { -// getLog().warn("could not retreave project '" + projectId + "', for reason " + e.getMessage(), e); -// return false; -// } -// } -// -// protected boolean initReleaseVersion() throws MojoExecutionException { -// -// if (versionId == null || versionId.trim().isEmpty()) { -// throw new MojoExecutionException("required a versionId parameter"); -// } -// -// try { -// -// Version v = service.getVersion(projectId, versionId); -// -// if (v == null) { -// -// return false; -// } -// -// releaseVersion = v; -// return true; -// } catch (RedmineServiceException e) { -// getLog().warn("could not retreave version '" + versionId + "', for reason " + e.getMessage(), e); -// return false; -// } -// } -// -// protected boolean initReleaseUser() { -// -// try { -// users = service.getProjectMembers(projectId); -// -// User user = ModelHelper.byLogin(username, users); -// -// if (user == null) { -// -// return false; -// } -// -// releaseUser = user; -// return true; -// } catch (RedmineServiceException e) { -// getLog().warn("could not retreave user '" + username + "', for reason " + e.getMessage(), e); -// return false; -// } -// } - protected void closeService() { if (service != null) { - RedmineServiceImplementor i; - i = (RedmineServiceImplementor) service; - - if (i.isInit()) { - try { - if (verbose) { - getLog().info("<<< Close redmine rest client..."); - } - i.destroy(); - } catch (Exception ex) { - getLog().error("could not close redmine client for reason " + ex.getMessage(), ex); - } + try { + service.destroy(); + } catch (Exception ex) { + getLog().error("could not close redmine client for reason " + ex.getMessage(), ex); } + } } @@ -467,12 +342,4 @@ public void setSafe(boolean safe) { this.safe = safe; } - -// public String getProjectId() { -// return projectId; -// } -// -// public String getVersionId() { -// return versionId; -// } } Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/DisplayDataMojo.java 2012-07-15 19:09:51 UTC (rev 308) @@ -27,7 +27,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.nuiton.jredmine.RedmineServiceImplementor; import org.nuiton.jredmine.model.I18nAble; import org.nuiton.jredmine.model.IdAble; import org.nuiton.jredmine.model.ModelHelper; @@ -207,7 +206,7 @@ RedmineModelScope scope = entry.getScope(); String requestName = entry.getRequestAll(); - IdAble[] datas = (IdAble[]) ((RedmineServiceImplementor) service).getDatas(requestName, entry.getModelType(), projectId, versionId); + IdAble[] datas = (IdAble[]) service.getDelegateImplementor().getDatas(requestName, entry.getModelType(), projectId, versionId); List<IdAble> list = Arrays.asList(datas); if (sortById) { Collections.sort(list, ModelHelper.ID_ABLE_COMPARATOR); Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/LoginMojo.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/LoginMojo.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/LoginMojo.java 2012-07-15 19:09:51 UTC (rev 308) @@ -32,8 +32,8 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; import org.nuiton.helper.plugin.ShareServerSecretPlugin; -import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.jredmine.RedmineService; +import org.nuiton.jredmine.RedmineServiceConfiguration; import org.nuiton.jredmine.RedmineServiceImplementor; import org.nuiton.plugin.AbstractPlugin; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; @@ -47,7 +47,7 @@ * @since 1.2.1 */ @Mojo(name = "login", requiresOnline = true, requiresProject = true) -public class LoginMojo extends AbstractPlugin implements RestClientConfiguration { +public class LoginMojo extends AbstractPlugin implements RedmineServiceConfiguration { /** * Dependance du projet. Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/main/java/org/nuiton/jredmine/plugin/announcement/AbstractAnnouncementMojo.java 2012-07-15 19:09:51 UTC (rev 308) @@ -247,7 +247,7 @@ protected boolean checkRunOnceDone() { String template = getAnnouncementTemplate(); - File out = new File(templateOutputDirectory, template); + File out = getOutputFile(); Date buildStartTime = session == null ? null : session.getStartTime(); Date newStartTime = out.exists() ? new Date(out.lastModified()) : null; @@ -349,7 +349,7 @@ //TODO-TC-20091209 must obtain back the full name of dev from the project team on each action String template = getAnnouncementTemplate(); - File out = new File(templateOutputDirectory, template); + File out = getOutputFile(); getLog().info("Apply template [" + template + "]"); getLog().info(" from : " + xmlPath); @@ -449,4 +449,8 @@ public Map<String, Object> getAnnounceParameters() { return announceParameters; } + + protected File getOutputFile() { + return new File(templateOutputDirectory, getAnnouncementTemplate()); + } } Added: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineAnonymousFixtureClassRule.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineAnonymousFixtureClassRule.java (rev 0) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineAnonymousFixtureClassRule.java 2012-07-15 19:09:51 UTC (rev 308) @@ -0,0 +1,63 @@ +package org.nuiton.jredmine; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assume; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import java.io.IOException; + +/** + * A class rule that provider the {@link RedmineFixtures} and check that the + * valid anonymous configuration is found. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class RedmineAnonymousFixtureClassRule implements TestRule { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(RedmineAnonymousFixtureClassRule.class); + + RedmineFixtures fixtures = new RedmineFixtures(); + + RedmineServiceConfiguration conf; + + @Override + public Statement apply(Statement base, Description description) { + + Class<?> testClass = description.getTestClass(); + + try { + conf = fixtures.obtainRedmineConfiguration(); + + if (conf == null) { + + // could not find any configuration + if (log.isWarnEnabled()) { + log.warn("could not connect to server " + + fixtures.newAnonymousConfiguration() + ", will skip test " + + testClass.getName()); + } + Assume.assumeTrue(false); + } + // since having a configuration available, is by force anonymous + + } catch (IOException e) { + throw new IllegalStateException("Could not check jredmine configuration in test " + testClass.getName(), e); + + } + return base; + } + + public RedmineFixtures getFixtures() { + return fixtures; + } + + public RedmineServiceConfiguration getConf() { + return conf; + } +} Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineFixtures.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineFixtures.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineFixtures.java 2012-07-15 19:09:51 UTC (rev 308) @@ -1,33 +1,19 @@ package org.nuiton.jredmine; import com.google.common.base.Charsets; -import com.google.common.collect.ArrayListMultimap; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.io.rest.RestClientConfiguration; -import org.nuiton.jredmine.model.Attachment; -import org.nuiton.jredmine.model.Issue; -import org.nuiton.jredmine.model.IssueCategory; -import org.nuiton.jredmine.model.IssuePriority; -import org.nuiton.jredmine.model.IssueStatus; -import org.nuiton.jredmine.model.News; -import org.nuiton.jredmine.model.Project; -import org.nuiton.jredmine.model.TimeEntry; -import org.nuiton.jredmine.model.Tracker; -import org.nuiton.jredmine.model.User; -import org.nuiton.jredmine.model.Version; -import org.nuiton.jredmine.model.io.xpp3.RedmineDataConverter; +import org.nuiton.io.rest.RestException; +import org.nuiton.jredmine.rest.RedmineRestClient; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import java.util.Date; -import java.util.List; import java.util.Properties; /** @@ -41,22 +27,10 @@ /** Logger. */ private static final Log log = LogFactory.getLog(RedmineFixtures.class); - public static final String FILE_TO_UPLOAD_CONTENT = "Fichier à uploader"; -// -// public static final String PROJECT_NAME = "jredmine"; -// -// public static final String VERSION_NAME = "1.3"; -// -// public static final String ISSUE_ID = "1925"; + private RedmineServiceConfiguration anonymousConfiguration; - private Project JRedmineProject; + private RedmineServiceConfiguration logguedConfiguration; - private ArrayListMultimap<Class<?>, Object> model; - - private RestClientConfiguration anonymousConfiguration; - - private RestClientConfiguration logguedConfiguration; - public String projectName() { return "jredmine"; } @@ -73,35 +47,108 @@ return "1925"; } - public RestClientConfiguration newAnonymousConfiguration() + public RedmineServiceConfiguration newAnonymousConfiguration() throws IOException { - RestClientConfiguration conf = new FakeRedmineServiceConfiguration(); + RedmineServiceConfiguration conf = new FakeRedmineServiceConfiguration(); copyConfiguration(getAnonymousConfiguration(), conf); return conf; } - public RestClientConfiguration newLogguedConfiguration() + public RedmineServiceConfiguration newLogguedConfiguration() throws IOException { - RestClientConfiguration conf = new FakeRedmineServiceConfiguration(); + RedmineServiceConfiguration conf = new FakeRedmineServiceConfiguration(); copyConfiguration(getLogguedConfiguration(), conf); return conf; } - public RedmineAnonymousService newRedmineAnonymousService(RestClientConfiguration configuration) + public RedmineAnonymousService newRedmineAnonymousService(RedmineServiceConfiguration configuration) throws IOException, RedmineServiceException { - DefaultRedmineAnonymousService service = new DefaultRedmineAnonymousService(); + RedmineAnonymousService service = new DefaultRedmineAnonymousService(); service.init(configuration); return service; } - public RedmineService newRedmineService(RestClientConfiguration configuration) + public RedmineService newRedmineService(RedmineServiceConfiguration configuration) throws IOException, RedmineServiceException { - DefaultRedmineService service = new DefaultRedmineService(); + RedmineService service = new DefaultRedmineService(); service.init(configuration); return service; } - protected RestClientConfiguration getAnonymousConfiguration() + public void copyConfiguration(RedmineServiceConfiguration src, + RedmineServiceConfiguration dst) { + dst.setRestUrl(src.getRestUrl()); + dst.setRestUsername(src.getRestUsername()); + dst.setRestPassword(src.getRestPassword()); + dst.setEncoding(src.getEncoding()); + dst.setVerbose(src.isVerbose()); + dst.setAnonymous(src.isAnonymous()); + } + + public RedmineServiceConfiguration obtainRedmineConfiguration() throws IOException { + + RedmineServiceConfiguration conf = newLogguedConfiguration(); + + boolean ok = false; + + RedmineRestClient client = new RedmineRestClient(conf); + + try { + + client.open(); + ok = client.isOpen(); + } catch (Exception e) { + + if (log.isDebugEnabled()) { + log.debug("Could not connect to redmine with configuration: " + conf, e); + } + + } finally { + try { + client.close(); + } catch (RestException e) { + if (log.isErrorEnabled()) { + log.error("Could not close session", e); + } + } + } + + if (!ok) { + + // try to connect anonymous + conf = newAnonymousConfiguration(); + + client = new RedmineRestClient(conf); + + try { + + client.open(); + ok = client.isOpen(); + } catch (Exception e) { + + if (log.isDebugEnabled()) { + log.debug("Could not connect to redmine with configuration: " + conf, e); + } + } finally { + try { + client.close(); + } catch (RestException e) { + if (log.isErrorEnabled()) { + log.error("Could not close session", e); + } + } + } + } + + if (!ok) { + + // no conf available + conf = null; + } + return conf; + } + + protected RedmineServiceConfiguration getAnonymousConfiguration() throws IOException { if (anonymousConfiguration == null) { @@ -158,13 +205,13 @@ return anonymousConfiguration; } - protected RestClientConfiguration getLogguedConfiguration() + protected RedmineServiceConfiguration getLogguedConfiguration() throws IOException { if (logguedConfiguration == null) { // use anonymous configuration - RestClientConfiguration anoConf = getAnonymousConfiguration(); + RedmineServiceConfiguration anoConf = getAnonymousConfiguration(); if (anoConf != null) { logguedConfiguration = new FakeRedmineServiceConfiguration(); copyConfiguration(anoConf, logguedConfiguration); @@ -184,528 +231,13 @@ return logguedConfiguration; } - public void copyConfiguration(RestClientConfiguration src, - RestClientConfiguration dst) { - dst.setRestUrl(src.getRestUrl()); - dst.setRestUsername(src.getRestUsername()); - dst.setRestPassword(src.getRestPassword()); - dst.setEncoding(src.getEncoding()); - dst.setVerbose(src.isVerbose()); - dst.setAnonymous(src.isAnonymous()); - } - - public List<Attachment> getAttachments() { - return get(Attachment.class); - } - - public List<Issue> getIssues() { - return get(Issue.class); - } - - public List<Project> getProjects() { - return get(Project.class); - } - - public List<Tracker> getTrackers() { - return get(Tracker.class); - } - - public List<User> getUsers() { - return get(User.class); - } - - public List<Version> getVersions() { - return get(Version.class); - } - - public <T> List<T> get(Class<T> modelType) { - if (model == null) { - try { - loadModel(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - return (List<T>) model.get(modelType); - } - - public <T> T get(Class<T> type, int pos) { - List<T> ts = get(type); - return ts.get(pos); - } - - public Project getJRedmineProject() { - if (JRedmineProject == null) { - JRedmineProject = new Project(); - JRedmineProject.setName("jredmine"); - JRedmineProject.setIdentifier("jredmine"); - JRedmineProject.setIsPublic(true); - JRedmineProject.setHomepage("http://maven-site.nuiton.org/jredmine"); - JRedmineProject.setDescription( - "Permet de communiquer en java avec un serveur " + "redmine qui a installé le plugin rails jredmine"); - JRedmineProject.setId(36); - JRedmineProject.setStatus(1); - } - return JRedmineProject; - } - - - public static final String VERSION_TO_CREATE_NAME = "do_not_use_me"; - - public Version getVersion() { - Version version = new Version(); - version.setName(VERSION_TO_CREATE_NAME); - version.setDescription("Une version créée par les tests de jredmine," + - " ne pas utiliser,et modifiée"); - return version; - } - - private void loadModel() - throws Exception { - model = ArrayListMultimap.create(); - - Attachment tempA; - tempA = new Attachment(); - tempA.setAuthorId((Integer) RedmineDataConverter.Integer.convert("4")); - tempA.setContainerId((Integer) RedmineDataConverter.Integer.convert("1")); - tempA.setId((Integer) RedmineDataConverter.Integer.convert("1")); - tempA.setFilesize((Integer) RedmineDataConverter.Integer.convert("411")); - tempA.setDownloads((Integer) RedmineDataConverter.Integer.convert("0")); - tempA.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T12:56:41+02:00")); - tempA.setContainerType((String) RedmineDataConverter.Text.convert("Version")); - tempA.setContentType((String) RedmineDataConverter.Text.convert("application/json")); - tempA.setDigest((String) RedmineDataConverter.Text.convert("6ea84342c7475c05fb077b4aca832f9a")); - tempA.setDiskFilename((String) RedmineDataConverter.Text.convert("090905125641_get_issue.json")); - tempA.setFilename((String) RedmineDataConverter.Text.convert("get_issue.json")); - model.put(Attachment.class, tempA); - tempA = new Attachment(); - tempA.setAuthorId((Integer) RedmineDataConverter.Integer.convert("4")); - tempA.setContainerId((Integer) RedmineDataConverter.Integer.convert("1")); - tempA.setId((Integer) RedmineDataConverter.Integer.convert("1")); - tempA.setFilesize((Integer) RedmineDataConverter.Integer.convert("411")); - tempA.setDownloads((Integer) RedmineDataConverter.Integer.convert("0")); - tempA.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T12:56:41+02:00")); - tempA.setContainerType((String) RedmineDataConverter.Text.convert("Version")); - tempA.setContentType((String) RedmineDataConverter.Text.convert("application/json")); - tempA.setDigest((String) RedmineDataConverter.Text.convert("6ea84342c7475c05fb077b4aca832f9a")); - tempA.setDiskFilename((String) RedmineDataConverter.Text.convert("090905125641_get_issue.json2")); - tempA.setFilename((String) RedmineDataConverter.Text.convert("get_issue.json2")); - model.put(Attachment.class, tempA); - - Issue tempI; - tempI = new Issue(); - tempI.setAuthorId((Integer) RedmineDataConverter.Integer.convert("5")); - tempI.setCategoryId((Integer) RedmineDataConverter.Integer.convert("2")); - tempI.setDoneRatio((Integer) RedmineDataConverter.Integer.convert("0")); - tempI.setLockVersion((Integer) RedmineDataConverter.Integer.convert("7")); - tempI.setPriorityId((Integer) RedmineDataConverter.Integer.convert("4")); - tempI.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempI.setStatusId((Integer) RedmineDataConverter.Integer.convert("3")); - tempI.setTrackerId((Integer) RedmineDataConverter.Integer.convert("1")); - tempI.setFixedVersionId((Integer) RedmineDataConverter.Integer.convert("1")); - tempI.setId((Integer) RedmineDataConverter.Integer.convert("3")); - tempI.setParentId((Integer) RedmineDataConverter.Integer.convert("3")); - tempI.setRootId((Integer) RedmineDataConverter.Integer.convert("3")); - tempI.setLft((Integer) RedmineDataConverter.Integer.convert("1")); - tempI.setRgt((Integer) RedmineDataConverter.Integer.convert("2")); - tempI.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T20:11:52+02:00")); - tempI.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T00:37:40+02:00")); - tempI.setStartDate((Date) RedmineDataConverter.Date.convert("2009-09-04")); - tempI.setDescription((String) RedmineDataConverter.Text.convert("avec une description !")); - tempI.setSubject((String) RedmineDataConverter.Text.convert("yes!")); - model.put(Issue.class, tempI); - tempI = new Issue(); - tempI.setAuthorId((Integer) RedmineDataConverter.Integer.convert("5")); - tempI.setCategoryId((Integer) RedmineDataConverter.Integer.convert("2")); - tempI.setDoneRatio((Integer) RedmineDataConverter.Integer.convert("0")); - tempI.setLockVersion((Integer) RedmineDataConverter.Integer.convert("7")); - tempI.setPriorityId((Integer) RedmineDataConverter.Integer.convert("4")); - tempI.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempI.setStatusId((Integer) RedmineDataConverter.Integer.convert("3")); - tempI.setTrackerId((Integer) RedmineDataConverter.Integer.convert("1")); - tempI.setFixedVersionId((Integer) RedmineDataConverter.Integer.convert("1")); - tempI.setId((Integer) RedmineDataConverter.Integer.convert("4")); - tempI.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T20:11:52+02:00")); - tempI.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T00:37:40+02:00")); - tempI.setStartDate((Date) RedmineDataConverter.Date.convert("2009-09-04")); - tempI.setDescription((String) RedmineDataConverter.Text.convert("avec une description !2")); - tempI.setSubject((String) RedmineDataConverter.Text.convert("yes!2")); - model.put(Issue.class, tempI); - - Project tempP; - tempP = new Project(); - tempP.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:11:54+02:00")); - tempP.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:11:54+02:00")); - tempP.setIdentifier((String) RedmineDataConverter.Text.convert("one")); - tempP.setName((String) RedmineDataConverter.Text.convert("one")); - tempP.setId((Integer) RedmineDataConverter.Integer.convert("1")); - tempP.setLft((Integer) RedmineDataConverter.Integer.convert("1")); - tempP.setRgt((Integer) RedmineDataConverter.Integer.convert("2")); - tempP.setProjectsCount((Integer) RedmineDataConverter.Integer.convert("0")); - tempP.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); - tempP.setIsPublic((Boolean) RedmineDataConverter.Boolean.convert("true")); - model.put(Project.class, tempP); - tempP = new Project(); - tempP.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T16:22:14+02:00")); - tempP.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T16:22:29+02:00")); - tempP.setIdentifier((String) RedmineDataConverter.Text.convert("two")); - tempP.setName((String) RedmineDataConverter.Text.convert("two")); - tempP.setId((Integer) RedmineDataConverter.Integer.convert("2")); - tempP.setProjectsCount((Integer) RedmineDataConverter.Integer.convert("0")); - tempP.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); - tempP.setIsPublic((Boolean) RedmineDataConverter.Boolean.convert("false")); - model.put(Project.class, tempP); - - Tracker tempT; - tempT = new Tracker(); - tempT.setId((Integer) RedmineDataConverter.Integer.convert("1")); - tempT.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempT.setTrackerId((Integer) RedmineDataConverter.Integer.convert("1")); - tempT.setPosition((Integer) RedmineDataConverter.Integer.convert("1")); - tempT.setIsInChlog((Boolean) RedmineDataConverter.Boolean.convert("true")); - tempT.setIsInRoadmap((Boolean) RedmineDataConverter.Boolean.convert("false")); - tempT.setName((String) RedmineDataConverter.Text.convert("Anomalie")); - model.put(Tracker.class, tempT); - tempT = new Tracker(); - tempT.setId((Integer) RedmineDataConverter.Integer.convert("2")); - tempT.setIsInChlog((Boolean) RedmineDataConverter.Boolean.convert("true")); - tempT.setIsInRoadmap((Boolean) RedmineDataConverter.Boolean.convert("true")); - tempT.setName((String) RedmineDataConverter.Text.convert("Evolution")); - tempT.setPosition((Integer) RedmineDataConverter.Integer.convert("2")); - tempT.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempT.setTrackerId((Integer) RedmineDataConverter.Integer.convert("2")); - model.put(Tracker.class, tempT); - tempT = new Tracker(); - tempT.setId((Integer) RedmineDataConverter.Integer.convert("3")); - tempT.setIsInChlog((Boolean) RedmineDataConverter.Boolean.convert("false")); - tempT.setIsInRoadmap((Boolean) RedmineDataConverter.Boolean.convert("false")); - tempT.setName((String) RedmineDataConverter.Text.convert("Assistance")); - tempT.setPosition((Integer) RedmineDataConverter.Integer.convert("3")); - tempT.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempT.setTrackerId((Integer) RedmineDataConverter.Integer.convert("3")); - model.put(Tracker.class, tempT); - - User tempU; - tempU = new User(); - tempU.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T17:24:46+02:00")); - tempU.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T01:23:59+02:00")); - tempU.setLastLoginOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T01:23:59+02:00")); - tempU.setId((Integer) RedmineDataConverter.Integer.convert("1")); - tempU.setMemberId((Integer) RedmineDataConverter.Integer.convert("5")); - tempU.setRoleId((Integer) RedmineDataConverter.Integer.convert("3")); - tempU.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); - tempU.setAdmin((Boolean) RedmineDataConverter.Boolean.convert("true")); - tempU.setMailNotification((Boolean) RedmineDataConverter.Boolean.convert("true")); - tempU.setFirstname((String) RedmineDataConverter.Text.convert("Redmine")); - tempU.setHashedPassword( - (String) RedmineDataConverter.Text.convert("70c881d4a26984ddce795f6f71817c9cf4480e79")); - tempU.setLanguage((String) RedmineDataConverter.Text.convert("fr")); - tempU.setLastname((String) RedmineDataConverter.Text.convert("Admin")); - tempU.setLogin((String) RedmineDataConverter.Text.convert("admin")); - tempU.setMail((String) RedmineDataConverter.Text.convert("dummy@codelutin.com")); - tempU.setIdentityUrl((String) RedmineDataConverter.Text.convert("yo")); - model.put(User.class, tempU); - tempU = new User(); - tempU.setAdmin((Boolean) RedmineDataConverter.Boolean.convert("true")); - tempU.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T19:49:02+02:00")); - tempU.setFirstname((String) RedmineDataConverter.Text.convert("tony")); - tempU.setHashedPassword( - (String) RedmineDataConverter.Text.convert("8aed1322e5450badb078e1fb60a817a1df25a2ca")); - tempU.setId((Integer) RedmineDataConverter.Integer.convert("5")); - tempU.setLanguage((String) RedmineDataConverter.Text.convert("fr")); - tempU.setLastLoginOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T19:49:38+02:00")); - tempU.setLastname((String) RedmineDataConverter.Text.convert("chemit2")); - tempU.setLogin((String) RedmineDataConverter.Text.convert("tchemit2")); - tempU.setMail((String) RedmineDataConverter.Text.convert("chemit@codelutin.com")); - tempU.setMailNotification((Boolean) RedmineDataConverter.Boolean.convert("false")); - tempU.setMemberId((Integer) RedmineDataConverter.Integer.convert("4")); - tempU.setRoleId((Integer) RedmineDataConverter.Integer.convert("3")); - tempU.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); - tempU.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T19:49:38+02:00")); - model.put(User.class, tempU); - tempU = new User(); - tempU.setAdmin((Boolean) RedmineDataConverter.Boolean.convert("false")); - tempU.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T16:24:11+02:00")); - tempU.setFirstname((String) RedmineDataConverter.Text.convert("dev")); - tempU.setHashedPassword( - (String) RedmineDataConverter.Text.convert("70c881d4a26984ddce795f6f71817c9cf4480e79")); - tempU.setId((Integer) RedmineDataConverter.Integer.convert("7")); - tempU.setLanguage((String) RedmineDataConverter.Text.convert("fr")); - tempU.setLastLoginOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T16:34:39+02:00")); - tempU.setLastname((String) RedmineDataConverter.Text.convert("dev")); - tempU.setLogin((String) RedmineDataConverter.Text.convert("dev")); - tempU.setMail((String) RedmineDataConverter.Text.convert("dev3@ynot-home.info")); - tempU.setMailNotification((Boolean) RedmineDataConverter.Boolean.convert("false")); - tempU.setMemberId((Integer) RedmineDataConverter.Integer.convert("9")); - tempU.setRoleId((Integer) RedmineDataConverter.Integer.convert("4")); - tempU.setStatus((Integer) RedmineDataConverter.Integer.convert("1")); - tempU.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T16:34:39+02:00")); - model.put(User.class, tempU); - - Version tempV; - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:47:39+02:00")); - tempV.setDescription((String) RedmineDataConverter.Text.convert("yo")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("9")); - tempV.setName((String) RedmineDataConverter.Text.convert("yor")); - tempV.setSharing((String) RedmineDataConverter.Text.convert("none")); - tempV.setStatus((String) RedmineDataConverter.Text.convert("open")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:50:49+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:05:09+02:00")); - tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoye")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("13")); - tempV.setName((String) RedmineDataConverter.Text.convert("rrrrrrrrrouuuuuua")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:05:09+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:07:58+02:00")); - tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoye")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("15")); - tempV.setName((String) RedmineDataConverter.Text.convert("aaaauuuuuua")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:07:58+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T04:12:25+02:00")); - tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoyeppppppppppppppppp")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("16")); - tempV.setName((String) RedmineDataConverter.Text.convert("aaaau")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T04:13:20+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:05:40+02:00")); - tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoye")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("14")); - tempV.setName((String) RedmineDataConverter.Text.convert("aaaaaaaaaarrrrrrrrrouuuuuua")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:05:40+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T00:39:15+02:00")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("5")); - tempV.setName((String) RedmineDataConverter.Text.convert("2")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-05T00:39:15+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:13:05+02:00")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setName((String) RedmineDataConverter.Text.convert("1.0.0")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-04T18:13:05+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:00:12+02:00")); - tempV.setDescription((String) RedmineDataConverter.Text.convert("yoye")); - tempV.setEffectiveDate((Date) RedmineDataConverter.Date.convert("2009-09-06")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("11")); - tempV.setName((String) RedmineDataConverter.Text.convert("yaouuuuuua")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:00:12+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:50:59+02:00")); - tempV.setDescription((String) RedmineDataConverter.Text.convert("yoye")); - tempV.setEffectiveDate((Date) RedmineDataConverter.Date.convert("2009-09-06")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("10")); - tempV.setName((String) RedmineDataConverter.Text.convert("ya")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T02:54:16+02:00")); - model.put(Version.class, tempV); - tempV = new Version(); - tempV.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:00:37+02:00")); - tempV.setDescription((String) RedmineDataConverter.Text.convert("ysssoye")); - tempV.setEffectiveDate((Date) RedmineDataConverter.Date.convert("2009-09-06")); - tempV.setId((Integer) RedmineDataConverter.Integer.convert("12")); - tempV.setName((String) RedmineDataConverter.Text.convert("ouuuuuua")); - tempV.setProjectId((Integer) RedmineDataConverter.Integer.convert("1")); - tempV.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-06T03:00:42+02:00")); - model.put(Version.class, tempV); - - IssueStatus tempIS; - tempIS = new IssueStatus(); - tempIS.setId(1); - tempIS.setName("Nouveau"); - tempIS.setPosition(1); - tempIS.setDefaultDoneRatio(10); - tempIS.setIsClosed(false); - tempIS.setIsDefault(true); - model.put(IssueStatus.class, tempIS); - tempIS = new IssueStatus(); - tempIS.setId(2); - tempIS.setName("Assigné"); - tempIS.setPosition(2); - tempIS.setIsClosed(false); - tempIS.setIsDefault(false); - model.put(IssueStatus.class, tempIS); - tempIS = new IssueStatus(); - tempIS.setId(3); - tempIS.setName("Résolu"); - tempIS.setPosition(3); - tempIS.setIsClosed(false); - tempIS.setIsDefault(false); - model.put(IssueStatus.class, tempIS); - tempIS = new IssueStatus(); - tempIS.setId(4); - tempIS.setName("Commentaire"); - tempIS.setPosition(4); - tempIS.setIsClosed(false); - tempIS.setIsDefault(false); - model.put(IssueStatus.class, tempIS); - tempIS = new IssueStatus(); - tempIS.setId(5); - tempIS.setName("Fermé"); - tempIS.setPosition(5); - tempIS.setIsClosed(true); - tempIS.setIsDefault(false); - model.put(IssueStatus.class, tempIS); - tempIS = new IssueStatus(); - tempIS.setId(6); - tempIS.setPosition(6); - tempIS.setName("Rejeté"); - tempIS.setIsClosed(true); - tempIS.setIsDefault(false); - model.put(IssueStatus.class, tempIS); - - IssuePriority tempIP; - tempIP = new IssuePriority(); - tempIP.setId(3); - tempIP.setParentId(1); - tempIP.setProjectId(2); - tempIP.setName("Bas"); - tempIP.setPosition(1); - tempIP.setOpt("IPRI"); - tempIP.setIsDefault(false); - tempIP.setActive(true); - model.put(IssuePriority.class, tempIP); - tempIP = new IssuePriority(); - tempIP.setId(4); - tempIP.setName("Normal"); - tempIP.setPosition(2); - tempIP.setOpt("IPRI"); - tempIP.setIsDefault(true); - model.put(IssuePriority.class, tempIP); - tempIP = new IssuePriority(); - tempIP.setId(5); - tempIP.setName("Haut"); - tempIP.setPosition(3); - tempIP.setOpt("IPRI"); - tempIP.setIsDefault(false); - model.put(IssuePriority.class, tempIP); - tempIP = new IssuePriority(); - tempIP.setId(6); - tempIP.setName("Urgent"); - tempIP.setPosition(4); - tempIP.setOpt("IPRI"); - tempIP.setIsDefault(false); - model.put(IssuePriority.class, tempIP); - tempIP = new IssuePriority(); - tempIP.setId(7); - tempIP.setName("Immédiat"); - tempIP.setPosition(5); - tempIP.setOpt("IPRI"); - tempIP.setIsDefault(false); - model.put(IssuePriority.class, tempIP); - - IssueCategory tempIC; - tempIC = new IssueCategory(); - tempIC.setId(1); - tempIC.setName("categorie one"); - tempIC.setProjectId(1); - model.put(IssueCategory.class, tempIC); - tempIC = new IssueCategory(); - tempIC.setId(2); - tempIC.setName("categorie two"); - tempIC.setProjectId(1); - model.put(IssueCategory.class, tempIC); - - News tempN; - tempN = new News(); - tempN.setId(85); - tempN.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-17T21:50:26+02:00")); - tempN.setProjectId(1); - tempN.setAuthorId(4); - tempN.setCommentsCount(0); - tempN.setDescription("description"); - tempN.setSummary("summary"); - tempN.setTitle("title"); - model.put(News.class, tempN); - tempN = new News(); - tempN.setId(86); - tempN.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-09-17T21:55:26+02:00")); - tempN.setProjectId(1); - tempN.setAuthorId(4); - tempN.setCommentsCount(0); - tempN.setDescription("description2"); - tempN.setSummary("summary2"); - tempN.setTitle("title2"); - model.put(News.class, tempN); - - TimeEntry tempE; - - tempE = new TimeEntry(); - tempE.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:02:02+01:00")); - tempE.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:02:02+01:00")); - tempE.setSpentOn((Date) RedmineDataConverter.Date.convert("2009-12-31")); - tempE.setId(1); - tempE.setProjectId(1); - tempE.setUserId(4); - tempE.setIssueId(6); - tempE.setActivityId(8); - - tempE.setHours(1); - tempE.setTmonth(12); - tempE.setTyear(2009); - tempE.setTweek(53); - tempE.setComments("Test"); - model.put(TimeEntry.class, tempE); - - tempE = new TimeEntry(); - tempE.setCreatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:10:01+01:00")); - tempE.setUpdatedOn((Date) RedmineDataConverter.Datetime.convert("2009-12-31T23:10:01+01:00")); - tempE.setSpentOn((Date) RedmineDataConverter.Date.convert("2009-12-31")); - tempE.setId(2); - tempE.setProjectId(1); - tempE.setUserId(4); - tempE.setIssueId(6); - tempE.setActivityId(9); - - tempE.setHours(2); - tempE.setTmonth(12); - tempE.setTyear(2009); - tempE.setTweek(53); - tempE.setComments("deuxième temps"); - model.put(TimeEntry.class, tempE); - } - - - public Attachment getAttachment() { - Attachment result = new Attachment(); - File fileToUpload = null; - try { - fileToUpload = File.createTempFile("toupload", ".txt"); - FileUtils.write(fileToUpload, FILE_TO_UPLOAD_CONTENT); - result.setToUpload(fileToUpload); - result.setDescription("attachment description..."); - return result; - } catch (IOException e) { - throw new RuntimeException("Could not create temp file", e); - } - - } - /** * Configuration of a redmine service for test purposes. * * @author tchemit <chemit@codelutin.com> * @since 1.4 */ - public static class FakeRedmineServiceConfiguration implements RestClientConfiguration { + public static class FakeRedmineServiceConfiguration implements RedmineServiceConfiguration { URL restUrl; @@ -781,8 +313,9 @@ @Override public String toString() { - ToStringBuilder b = new ToStringBuilder(this, - ToStringStyle.MULTI_LINE_STYLE + ToStringBuilder b = new ToStringBuilder( + this, + ToStringStyle.MULTI_LINE_STYLE ); b.append("redmineUrl", restUrl); if (anonymous) { Added: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineLogguedFixtureClassRule.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineLogguedFixtureClassRule.java (rev 0) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/RedmineLogguedFixtureClassRule.java 2012-07-15 19:09:51 UTC (rev 308) @@ -0,0 +1,74 @@ +package org.nuiton.jredmine; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assume; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +import java.io.IOException; + +/** + * A class rule that provider the {@link RedmineFixtures} and check that the + * valid loggued configuration is found. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.4 + */ +public class RedmineLogguedFixtureClassRule implements TestRule { + + /** Logger. */ + private static final Log log = + LogFactory.getLog(RedmineLogguedFixtureClassRule.class); + + RedmineFixtures fixtures = new RedmineFixtures(); + + RedmineServiceConfiguration conf; + + @Override + public Statement apply(Statement base, Description description) { + + Class<?> testClass = description.getTestClass(); + + try { + conf = fixtures.obtainRedmineConfiguration(); + + if (conf == null) { + + // could not find any configuration + if (log.isWarnEnabled()) { + log.warn("could not connect to server " + + fixtures.newAnonymousConfiguration() + ", will skip test " + + testClass.getName()); + } + Assume.assumeTrue(false); + } else { + + // configuration must NOT be anonymous + + if (conf.isAnonymous()) { + + if (log.isWarnEnabled()) { + log.warn("A authenticated configuration was required, will skip test " + + testClass.getName()); + } + Assume.assumeTrue(false); + } + } + + } catch (IOException e) { + throw new IllegalStateException("Could not check jredmine configuration in test " + testClass.getName(), e); + + } + return base; + } + + public RedmineFixtures getFixtures() { + return fixtures; + } + + public RedmineServiceConfiguration getConf() { + return conf; + } +} Added: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractAnonymousRedmineMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractAnonymousRedmineMojoTest.java (rev 0) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractAnonymousRedmineMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -0,0 +1,56 @@ +/* + * #%L + * JRedmine :: Maven plugin + * + * $Id: AbstractRedmineMojoTest.java 303 2012-07-15 11:14:29Z tchemit $ + * $HeadURL: http://svn.nuiton.org/svn/jredmine/branches/jredmine-1.x/jredmine-maven-plug... $ + * %% + * Copyright (C) 2009 - 2012 Tony Chemit, CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.jredmine.plugin; + +import org.junit.ClassRule; +import org.nuiton.jredmine.RedmineAnonymousFixtureClassRule; +import org.nuiton.jredmine.RedmineFixtures; +import org.nuiton.jredmine.RedmineServiceConfiguration; + +import java.io.IOException; + +/** + * @param <P> type of mojo to test + * @author tchemit <chemit@codelutin.com> + * @since 1.0.0 + */ +public abstract class AbstractAnonymousRedmineMojoTest<P extends AbstractRedmineMojo> extends AbstractRedmineMojoTest<P> { + + @ClassRule + public static final RedmineAnonymousFixtureClassRule classRule = + new RedmineAnonymousFixtureClassRule(); + + @Override + protected RedmineFixtures getFixtures() { + return classRule.getFixtures(); + } + + protected final RedmineServiceConfiguration getConfiguration() throws IOException { + // by default use a anonymous configuration + RedmineServiceConfiguration conf = getFixtures().newAnonymousConfiguration(); + return conf; + } + +} Added: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractLogguedRedmineMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractLogguedRedmineMojoTest.java (rev 0) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractLogguedRedmineMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -0,0 +1,55 @@ +/* + * #%L + * JRedmine :: Maven plugin + * + * $Id: AbstractRedmineMojoTest.java 303 2012-07-15 11:14:29Z tchemit $ + * $HeadURL: http://svn.nuiton.org/svn/jredmine/branches/jredmine-1.x/jredmine-maven-plug... $ + * %% + * Copyright (C) 2009 - 2012 Tony Chemit, CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.jredmine.plugin; + +import org.junit.ClassRule; +import org.nuiton.jredmine.RedmineFixtures; +import org.nuiton.jredmine.RedmineLogguedFixtureClassRule; +import org.nuiton.jredmine.RedmineServiceConfiguration; + +import java.io.IOException; + +/** + * @param <P> type of mojo to test + * @author tchemit <chemit@codelutin.com> + * @since 1.0.0 + */ +public abstract class AbstractLogguedRedmineMojoTest<P extends AbstractRedmineMojo> extends AbstractRedmineMojoTest<P> { + + @ClassRule + public static final RedmineLogguedFixtureClassRule classRule = + new RedmineLogguedFixtureClassRule(); + + @Override + protected RedmineFixtures getFixtures() { + return classRule.getFixtures(); + } + + protected final RedmineServiceConfiguration getConfiguration() throws IOException { + RedmineServiceConfiguration conf = getFixtures().newLogguedConfiguration(); + return conf; + } + +} Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractRedmineMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractRedmineMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/AbstractRedmineMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -24,13 +24,14 @@ */ package org.nuiton.jredmine.plugin; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.maven.model.IssueManagement; import org.codehaus.plexus.util.StringUtils; import org.junit.After; import org.junit.Assert; -import org.junit.BeforeClass; -import org.nuiton.io.rest.RestClientConfiguration; import org.nuiton.jredmine.RedmineFixtures; +import org.nuiton.jredmine.RedmineServiceConfiguration; import org.nuiton.plugin.AbstractMojoTest; import java.io.File; @@ -43,23 +44,20 @@ */ public abstract class AbstractRedmineMojoTest<P extends AbstractRedmineMojo> extends AbstractMojoTest<P> { - @BeforeClass - public static void atTheBegining() throws IOException { + /** Logger. */ + private static final Log log = + LogFactory.getLog(AbstractRedmineMojoTest.class); - fixtures = new RedmineFixtures(); - } + protected static boolean init; protected boolean canContinue; - protected static RedmineFixtures fixtures; + protected abstract RedmineServiceConfiguration getConfiguration() throws IOException; - protected RestClientConfiguration getConfiguration() throws IOException { - // by default use a anonymous configuration - RestClientConfiguration conf = fixtures.newAnonymousConfiguration(); - return conf; - } + protected abstract RedmineFixtures getFixtures(); protected void beforeMojoInit(P mojo, File pomFile) throws Exception { + // add a issue management IssueManagement i = new IssueManagement(); i.setSystem(AbstractRedmineMojo.REDMINE_SYSTEM); @@ -74,7 +72,7 @@ String projectId = redmineMojoWithProject.getProjectId(); if (StringUtils.isBlank(projectId)) { - redmineMojoWithProject.setProjectId(fixtures.projectName()); + redmineMojoWithProject.setProjectId(getFixtures().projectName()); } } @@ -86,7 +84,7 @@ String versionId = redmineMojoWithProjectAndVersion.getVersionId(); if (StringUtils.isBlank(versionId)) { - redmineMojoWithProjectAndVersion.setVersionId(fixtures.versionName()); + redmineMojoWithProjectAndVersion.setVersionId(getFixtures().versionName()); } } @@ -99,12 +97,13 @@ @Override protected void setUpMojo(P mojo, File pomFile) throws Exception { + super.setUpMojo(mojo, pomFile); - RestClientConfiguration configuration = getConfiguration(); + RedmineServiceConfiguration configuration = getConfiguration(); // copy redmine test server configuration - fixtures.copyConfiguration(configuration, mojo); + getFixtures().copyConfiguration(configuration, mojo); beforeMojoInit(mojo, pomFile); @@ -139,15 +138,16 @@ } protected void mojoDoAction() throws Exception { - if (!canContinue) { - return; + + if (canContinue) { + + P mojo = getMojo(); + Assert.assertNotNull(mojo); + try { + mojo.doAction(); + } finally { + mojo.afterExecute(); + } } - P mojo = getMojo(); - Assert.assertNotNull(mojo); - try { - mojo.doAction(); - } finally { - mojo.afterExecute(); - } } } Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/DisplayDataMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/DisplayDataMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/DisplayDataMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -30,7 +30,7 @@ * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class DisplayDataMojoTest extends AbstractRedmineMojoTest<DisplayDataMojo> { +public class DisplayDataMojoTest extends AbstractAnonymousRedmineMojoTest<DisplayDataMojo> { @Override protected String getGoalName(String methodName) { Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/GenerateChangesMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/GenerateChangesMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/GenerateChangesMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -25,27 +25,18 @@ package org.nuiton.jredmine.plugin; import org.junit.Test; -import org.nuiton.io.rest.RestClientConfiguration; -import java.io.IOException; - /** * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class GenerateChangesMojoTest extends AbstractRedmineMojoTest<GenerateChangesMojo> { +public class GenerateChangesMojoTest extends AbstractLogguedRedmineMojoTest<GenerateChangesMojo> { @Override protected String getGoalName(String methodName) { return "generate-changes"; } - @Override - protected RestClientConfiguration getConfiguration() throws IOException { - RestClientConfiguration conf = fixtures.newLogguedConfiguration(); - return conf; - } - @Test public void generateChanges() throws Exception { Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/NextVersionMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/NextVersionMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/NextVersionMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -25,27 +25,18 @@ package org.nuiton.jredmine.plugin; import org.junit.Test; -import org.nuiton.io.rest.RestClientConfiguration; -import java.io.IOException; - /** * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class NextVersionMojoTest extends AbstractRedmineMojoTest<NextVersionMojo> { +public class NextVersionMojoTest extends AbstractLogguedRedmineMojoTest<NextVersionMojo> { @Override protected String getGoalName(String methodName) { return "next-version"; } - @Override - protected RestClientConfiguration getConfiguration() throws IOException { - RestClientConfiguration conf = fixtures.newLogguedConfiguration(); - return conf; - } - @Test public void nextVersion() throws Exception { Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/PublishAttachmentsMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -25,28 +25,18 @@ package org.nuiton.jredmine.plugin; import org.junit.Test; -import org.nuiton.io.rest.RestClientConfiguration; -import java.io.IOException; - /** * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class PublishAttachmentsMojoTest extends AbstractRedmineMojoTest<PublishAttachmentsMojo> { +public class PublishAttachmentsMojoTest extends AbstractLogguedRedmineMojoTest<PublishAttachmentsMojo> { @Override protected String getGoalName(String methodName) { return "publish-attachments"; } - - @Override - protected RestClientConfiguration getConfiguration() throws IOException { - RestClientConfiguration conf = fixtures.newLogguedConfiguration(); - return conf; - } - @Test public void publishAttachments() throws Exception { Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/PublishNewsMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/PublishNewsMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/PublishNewsMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -25,28 +25,18 @@ package org.nuiton.jredmine.plugin; import org.junit.Test; -import org.nuiton.io.rest.RestClientConfiguration; -import java.io.IOException; - /** * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class PublishNewsMojoTest extends AbstractRedmineMojoTest<PublishNewsMojo> { +public class PublishNewsMojoTest extends AbstractLogguedRedmineMojoTest<PublishNewsMojo> { @Override protected String getGoalName(String methodName) { return "publish-news"; } - - @Override - protected RestClientConfiguration getConfiguration() throws IOException { - RestClientConfiguration conf = fixtures.newLogguedConfiguration(); - return conf; - } - @Test public void publishNews() throws Exception { Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/UpdateVersionMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/UpdateVersionMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/UpdateVersionMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -25,27 +25,18 @@ package org.nuiton.jredmine.plugin; import org.junit.Test; -import org.nuiton.io.rest.RestClientConfiguration; -import java.io.IOException; - /** * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class UpdateVersionMojoTest extends AbstractRedmineMojoTest<UpdateVersionMojo> { +public class UpdateVersionMojoTest extends AbstractLogguedRedmineMojoTest<UpdateVersionMojo> { @Override protected String getGoalName(String methodName) { return "update-version"; } - @Override - protected RestClientConfiguration getConfiguration() throws IOException { - RestClientConfiguration conf = fixtures.newLogguedConfiguration(); - return conf; - } - @Test public void updateVersion() throws Exception { Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/announcement/GenerateEmailAnnouncementMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/announcement/GenerateEmailAnnouncementMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/announcement/GenerateEmailAnnouncementMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -24,35 +24,44 @@ */ package org.nuiton.jredmine.plugin.announcement; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; import org.junit.Test; -import org.nuiton.io.rest.RestClientConfiguration; -import org.nuiton.jredmine.plugin.AbstractRedmineMojoTest; +import org.nuiton.jredmine.plugin.AbstractLogguedRedmineMojoTest; -import java.io.IOException; +import java.io.File; /** - * * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class GenerateEmailAnnouncementMojoTest extends AbstractRedmineMojoTest<GenerateEmailAnnouncementMojo> { +public class GenerateEmailAnnouncementMojoTest extends AbstractLogguedRedmineMojoTest<GenerateEmailAnnouncementMojo> { + /** Logger. */ + private static final Log log = + LogFactory.getLog(GenerateEmailAnnouncementMojoTest.class); + @Override protected String getGoalName(String methodName) { return "generate-email-announcement"; } - @Override - protected RestClientConfiguration getConfiguration() throws IOException { - RestClientConfiguration conf = fixtures.newLogguedConfiguration(); - return conf; - } - @Test public void generateEmailAnnouncement() throws Exception { + File outputFile = getMojo().getOutputFile(); + Assert.assertNotNull(outputFile); mojoDoAction(); - //TODO check file is generated + Assert.assertTrue(outputFile.exists()); + if (getMojo().isVerbose()) { + + String content = FileUtils.readFileToString(outputFile); + if (log.isInfoEnabled()) { + log.info("Announcement content:\n" + content); + } + } } @Test Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/announcement/GenerateNewsAnnouncementMojoTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/announcement/GenerateNewsAnnouncementMojoTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/announcement/GenerateNewsAnnouncementMojoTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -24,35 +24,45 @@ */ package org.nuiton.jredmine.plugin.announcement; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; import org.junit.Test; -import org.nuiton.io.rest.RestClientConfiguration; -import org.nuiton.jredmine.plugin.AbstractRedmineMojoTest; +import org.nuiton.jredmine.plugin.AbstractLogguedRedmineMojoTest; -import java.io.IOException; +import java.io.File; /** - * * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public class GenerateNewsAnnouncementMojoTest extends AbstractRedmineMojoTest<GenerateNewsAnnouncementMojo> { +public class GenerateNewsAnnouncementMojoTest extends AbstractLogguedRedmineMojoTest<GenerateNewsAnnouncementMojo> { + /** Logger. */ + private static final Log log = + LogFactory.getLog(GenerateNewsAnnouncementMojoTest.class); + @Override protected String getGoalName(String methodName) { return "generate-news-announcement"; } - @Override - protected RestClientConfiguration getConfiguration() throws IOException { - RestClientConfiguration conf = fixtures.newLogguedConfiguration(); - return conf; - } - @Test public void generateNewsAnnouncement() throws Exception { + File outputFile = getMojo().getOutputFile(); + Assert.assertNotNull(outputFile); + mojoDoAction(); - //TODO check file is generated + Assert.assertTrue(outputFile.exists()); + if (getMojo().isVerbose()) { + + String content = FileUtils.readFileToString(outputFile); + if (log.isInfoEnabled()) { + log.info("Announcement content:\n" + content); + } + } } @Test Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReportTest.java =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReportTest.java 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/java/org/nuiton/jredmine/plugin/report/AbstractIssuesReportTest.java 2012-07-15 19:09:51 UTC (rev 308) @@ -26,14 +26,14 @@ import org.junit.Assume; import org.junit.Test; -import org.nuiton.jredmine.plugin.AbstractRedmineMojoTest; +import org.nuiton.jredmine.plugin.AbstractLogguedRedmineMojoTest; /** * @param <P> type of issue reports to test * @author tchemit <chemit@codelutin.com> * @since 1.0.0 */ -public abstract class AbstractIssuesReportTest<P extends AbstractIssuesReport> extends AbstractRedmineMojoTest<P> { +public abstract class AbstractIssuesReportTest<P extends AbstractIssuesReport> extends AbstractLogguedRedmineMojoTest<P> { @Test public void issueReport() throws Exception { Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest/generateEmailAnnouncement.xml =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest/generateEmailAnnouncement.xml 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest/generateEmailAnnouncement.xml 2012-07-15 19:09:51 UTC (rev 308) @@ -33,6 +33,8 @@ <version>0</version> <modelVersion>4.0.0</modelVersion> + <name>JRedmine</name> + <description>JRedmine is a java redmine client</description> <build> <plugins> @@ -44,21 +46,6 @@ <xmlPath> target/test-classes/org/nuiton/jredmine/plugin/announcement/changes.xml </xmlPath> - <templateDirectory> - org/nuiton/jredmine/plugin/announcement - </templateDirectory> - <attachmentLinkTemplate> - %URL%/attachments/download/%FILE% - </attachmentLinkTemplate> - <emailAnnouncementTemplate> - release-email-announcement.vm - </emailAnnouncementTemplate> - <skipGenerateEmailAnnouncement>false</skipGenerateEmailAnnouncement> - <developmentTeam>One team</developmentTeam> - <urlDownload>http://mynuiton.org/projects/list_files/one</urlDownload> - <introduction> - The release 1.0.0 is the first release of this plugin... - </introduction> <templateEncoding>UTF-8</templateEncoding> </configuration> <executions> Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest/skipGenerateEmailAnnouncement.xml =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest/skipGenerateEmailAnnouncement.xml 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateEmailAnnouncementMojoTest/skipGenerateEmailAnnouncement.xml 2012-07-15 19:09:51 UTC (rev 308) @@ -44,21 +44,6 @@ <xmlPath> target/test-classes/org/nuiton/jredmine/plugin/announcement/changes.xml </xmlPath> - <templateDirectory> - org/nuiton/jredmine/plugin/announcement - </templateDirectory> - <emailAnnouncementTemplate> - release-email-announcement.vm - </emailAnnouncementTemplate> - <attachmentLinkTemplate> - %URL%/attachments/download/%FILE% - </attachmentLinkTemplate> - <skipGenerateEmailAnnouncement>true</skipGenerateEmailAnnouncement> - <developmentTeam>One team</developmentTeam> - <urlDownload>http://mynuiton.org/projects/list_files/one</urlDownload> - <introduction> - The release 1.0.0 is the first release of this plugin... - </introduction> <templateEncoding>UTF-8</templateEncoding> </configuration> <executions> Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest/generateNewsAnnouncement.xml =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest/generateNewsAnnouncement.xml 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest/generateNewsAnnouncement.xml 2012-07-15 19:09:51 UTC (rev 308) @@ -44,21 +44,6 @@ <xmlPath> target/test-classes/org/nuiton/jredmine/plugin/announcement/changes.xml </xmlPath> - <templateDirectory> - org/nuiton/jredmine/plugin/announcement - </templateDirectory> - <attachmentLinkTemplate> - %URL%/attachments/download/%FILE% - </attachmentLinkTemplate> - <newsAnnouncementTemplate> - release-news-announcement.vm - </newsAnnouncementTemplate> - <skipGenerateNewsAnnouncement>false</skipGenerateNewsAnnouncement> - <developmentTeam>One team</developmentTeam> - <urlDownload>http://mynuiton.org/projects/list_files/one</urlDownload> - <introduction> - The release 1.0.0 is the first release of this plugin... - </introduction> <templateEncoding>UTF-8</templateEncoding> </configuration> <executions> Modified: branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest/skipGenerateNewsAnnouncement.xml =================================================================== --- branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest/skipGenerateNewsAnnouncement.xml 2012-07-15 19:08:28 UTC (rev 307) +++ branches/jredmine-1.x/jredmine-maven-plugin/src/test/resources/org/nuiton/jredmine/plugin/announcement/generateNewsAnnouncementMojoTest/skipGenerateNewsAnnouncement.xml 2012-07-15 19:09:51 UTC (rev 308) @@ -44,21 +44,6 @@ <xmlPath> target/test-classes/org/nuiton/jredmine/plugin/announcement/changes.xml </xmlPath> - <templateDirectory> - org/nuiton/jredmine/plugin/announcement - </templateDirectory> - <attachmentLinkTemplate> - %URL%/attachments/download/%FILE% - </attachmentLinkTemplate> - <newsAnnouncementTemplate> - release-news-announcement.vm - </newsAnnouncementTemplate> - <skipGenerateNewsAnnouncement>true</skipGenerateNewsAnnouncement> - <developmentTeam>One team</developmentTeam> - <urlDownload>http://mynuiton.org/projects/list_files/one</urlDownload> - <introduction> - The release 1.0.0 is the first release of this plugin... - </introduction> <templateEncoding>UTF-8</templateEncoding> </configuration> <executions>
participants (1)
-
tchemit@users.nuiton.org