// Path: src/main/java/com/versionone/jenkins/SvnModification.java
// public class SvnModification implements VcsModification {
// 
//     private final SubversionChangeLogSet.LogEntry entry;
// 
//     public SvnModification(SubversionChangeLogSet.LogEntry logEntry) {
//         entry = logEntry;
//     }
// 
//     public String getUserName() {
//         return entry.getAuthor().getFullName();
//     }
// 
//     public String getComment() {
//         return entry.getMsg();
//     }
// 
//     /**
//      * @return date of commit or null if date cannot be parsed.
//      */
//     public Date getDate() {
//         String dateWithoutMicrosecond = removeMicrosecondFromDate(entry.getDate());
//         try {
//             final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
//             df.setTimeZone(TimeZone.getTimeZone("GMT"));
//             return df.parse(dateWithoutMicrosecond);
//         } catch (ParseException e) {
//             return null;
//         }
//     }
// 
//     private String removeMicrosecondFromDate(String date) {
//         String[] dateParts = date.split("\\.");
//         if (dateParts.length != 2 || dateParts[1].length() != 7) {
//             return date;
//         }
//         String millisecond = dateParts[1].substring(0, 3);
//         return dateParts[0] + "." + millisecond + "Z";
//     }
// 
//     public String getId() {
//         return String.valueOf(entry.getRevision());
//     }
// }


import hudson.scm.SubversionChangeLogSet;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import junit.framework.Assert;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.Test;
import com.versionone.jenkins.SvnModification;
package com.versionone.hudson;






public class SvnModificationTest {
    private Mockery mockery = new Mockery() {
        {
            setImposteriser(ClassImposteriser.INSTANCE);
        }
    };

    @Test
    public void getDate() throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+4"));
        final String gmtDate = "2012-01-12T08:43:41.359375Z";//SVN plugin returns date in GMT
        final String localDateWithoutMicrosecond = "2012-01-12T12:43:41.359Z";
        SvnModification modification = CreateSvnModification(gmtDate);

        Date date = modification.getDate();
        Assert.assertEquals(dateFormat.parse(localDateWithoutMicrosecond), date);
    }

    @Test
    public void getDateWithoutMicrosecond() throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'", Locale.US);
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+4"));
        final String gmtDate = "2012-01-12T08:43:41.359Z";//SVN plugin returns date in GMT
        final String localDate = "2012-01-12T12:43:41.359Z";
// Path: src/main/java/com/versionone/jenkins/SvnModification.java
// public class SvnModification implements VcsModification {
// 
//     private final SubversionChangeLogSet.LogEntry entry;
// 
//     public SvnModification(SubversionChangeLogSet.LogEntry logEntry) {
//         entry = logEntry;
//     }
// 
//     public String getUserName() {
//         return entry.getAuthor().getFullName();
//     }
// 
//     public String getComment() {
//         return entry.getMsg();
//     }
// 
//     /**
//      * @return date of commit or null if date cannot be parsed.
//      */
//     public Date getDate() {
//         String dateWithoutMicrosecond = removeMicrosecondFromDate(entry.getDate());
//         try {
//             final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
//             df.setTimeZone(TimeZone.getTimeZone("GMT"));
//             return df.parse(dateWithoutMicrosecond);
//         } catch (ParseException e) {
//             return null;
//         }
//     }
// 
//     private String removeMicrosecondFromDate(String date) {
//         String[] dateParts = date.split("\\.");
//         if (dateParts.length != 2 || dateParts[1].length() != 7) {
//             return date;
//         }
//         String millisecond = dateParts[1].substring(0, 3);
//         return dateParts[0] + "." + millisecond + "Z";
//     }
// 
//     public String getId() {
//         return String.valueOf(entry.getRevision());
//     }
// }


// Path: src/test/java/com/versionone/hudson/SvnModificationTest.java
import hudson.scm.SubversionChangeLogSet;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import junit.framework.Assert;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.Test;
import com.versionone.jenkins.SvnModification;

package com.versionone.hudson;






public class SvnModificationTest {
    private Mockery mockery = new Mockery() {
        {
            setImposteriser(ClassImposteriser.INSTANCE);
        }
    };

    @Test
    public void getDate() throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+4"));
        final String gmtDate = "2012-01-12T08:43:41.359375Z";//SVN plugin returns date in GMT
        final String localDateWithoutMicrosecond = "2012-01-12T12:43:41.359Z";
        SvnModification modification = CreateSvnModification(gmtDate);

        Date date = modification.getDate();
        Assert.assertEquals(dateFormat.parse(localDateWithoutMicrosecond), date);
    }

    @Test
    public void getDateWithoutMicrosecond() throws ParseException {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'", Locale.US);
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+4"));
        final String gmtDate = "2012-01-12T08:43:41.359Z";//SVN plugin returns date in GMT
        final String localDate = "2012-01-12T12:43:41.359Z";
        SvnModification modification = CreateSvnModification(gmtDate);