Skip to content

Package: DiffFileGenerator

DiffFileGenerator

nameinstructionbranchcomplexitylinemethod
DiffFileGenerator()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
generateDiffFile(FilePackage, Version, Version)
M: 4 C: 41
91%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 1 C: 11
92%
M: 0 C: 1
100%
generateUrl(String, String, String)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: package migration;
2:
3: import java.io.ByteArrayOutputStream;
4:
5: import org.tmatesoft.svn.core.SVNDepth;
6: import org.tmatesoft.svn.core.SVNException;
7: import org.tmatesoft.svn.core.SVNURL;
8: import org.tmatesoft.svn.core.wc.SVNClientManager;
9: import org.tmatesoft.svn.core.wc.SVNRevision;
10:
11: /**
12: * Generates the diff-file based on the fli4l repository.
13: *
14: * @author Jannik
15: *
16: */
17: public class DiffFileGenerator {
18:
19:         /**
20:          * Generate a Diff-File.
21:          *
22:          * @param filePackage
23:          * the filePackage
24:          * @param baseVersion
25:          * the baseVersion
26:          * @param targetVersion
27:          * the targetVersion
28:          * @return the Diff-File
29:          * @throws SVNException
30:          * if there is a problem with the SVNKit.
31:          */
32:         public String generateDiffFile(final FilePackage filePackage, final Version baseVersion,
33:                         final Version targetVersion) throws SVNException {
34:                 final SVNClientManager svnClientManager = SVNClientManager.newInstance();
35:                 svnClientManager.createRepository(
36:                                 SVNURL.parseURIEncoded("https://repo.nettworks.org/svn/fli4l/"), false);
37:                 final ByteArrayOutputStream resultOutputStream = new ByteArrayOutputStream();
38:                 svnClientManager.getDiffClient()
39:                                 .doDiff(generateUrl(filePackage.getPackageName(), filePackage.getPath(),
40:                                                 baseVersion.getVersion()),
41:                                                 SVNRevision.create(baseVersion.getRevisionId()),
42:                                                 generateUrl(filePackage.getPackageName(), filePackage.getPath(),
43:                                                                 targetVersion.getVersion()),
44:                                                 SVNRevision.create(targetVersion.getRevisionId()), SVNDepth.INFINITY,
45:                                                 false, resultOutputStream);
46:                 return resultOutputStream.toString();
47:         }
48:
49:         /**
50:          *
51:          * Generate the SVN-Url to the version in the fli4l repo.
52:          *
53:          * @param packageName
54:          * the packageName
55:          * @param path
56:          * the path
57:          * @param baseVersion
58:          * the baseVersion
59:          * @return the SVN-Url to the version in the fli4l repo
60:          * @throws SVNException
61:          * if there is a problem with the SVNKit.
62:          */
63:         private SVNURL generateUrl(final String packageName, final String path,
64:                         final String baseVersion) throws SVNException {
65:                 return SVNURL.parseURIEncoded("https://repo.nettworks.org/svn/fli4l/branches/"
66:                                 + baseVersion + "/trunk/src/packages/" + packageName + "/" + path);
67:         }
68:
69: }