View Javadoc
1   /*
2    * Copyright 2014 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 1.0 (the
5    * "License"); you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl1.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.kuali.student.git.model;
17  
18  import java.io.IOException;
19  import java.util.Arrays;
20  
21  import org.eclipse.jgit.lib.Constants;
22  import org.eclipse.jgit.lib.Repository;
23  import org.junit.Test;
24  import org.junit.runner.RunWith;
25  import org.junit.runners.BlockJUnit4ClassRunner;
26  import org.kuali.student.git.model.ref.exception.BranchRefExistsException;
27  import org.kuali.student.git.model.utils.GitTestUtils;
28  
29  /**
30   * 
31   * Test the importer on KS Revision 65409 and 65443 which lose track of a key branch during renaming processes.
32   * 
33   * @author Kuali Student Team
34   *
35   */
36  @RunWith(BlockJUnit4ClassRunner.class)
37  public class TestKSRevision65409To65443 extends AbstractGitImporterMainTestCase {
38  
39  	/**
40  	 * @param name
41  	 */
42  	public TestKSRevision65409To65443() {
43  		super("ks-r65409-to-r65443", true);
44  	}
45  
46  	@Test
47  	public void testImport () throws IOException, BranchRefExistsException {
48  		
49  		runImporter (repository, 65409);
50  		
51  		// test that the ks-ap/trunk branch was created
52  		
53  		GitTestUtils.assertRefNotNull(repository, "enrollment_ks-ap_trunk", "ks-ap trunk should exist");
54  		
55  		GitTestUtils.assertPathsExist (repository, "enrollment_ks-ap_trunk", Arrays.asList(new String [] {"ks-ap-ui/src/main/resources", "ks-ap-web"}));
56  		
57  		// inject copyfrom data for enrollment/ks-ap/trunk from 65424
58  		
59  		runImporter (repository,  65425);
60  		
61  		// ks-ap trunk should have been deleted
62  		GitTestUtils.assertRefNull(repository, "enrollment_ks-ap_trunk", "ks-ap trunk should be null (deleted)");
63  		
64  		GitTestUtils.assertRefNotNull(repository, "enrollment_ks-ap_branches_inactive_KSAP", "enrollment_ks-ap_branches_inactive_KSAP should exist");
65  		
66  		GitTestUtils.assertRefNotNull(repository, "enrollment_ks-ap_trunk@65424", "enrollment_ks-ap_trunk@65424 should exist");
67  		
68  		GitTestUtils.assertPathsExist (repository, "enrollment_ks-ap_trunk@65424", Arrays.asList(new String [] {"ks-ap-ui/src/main/resources", "ks-ap-web"}));
69  		
70  		
71  		/*
72  		 * thinking about creating a branch here for ks-ap/branches/inactive/KSAP-M8
73  		 */
74  		
75  		GitTestUtils.createBranch (repository, Constants.R_HEADS + "enrollment_ks-ap_branches_inactive_KSAP-M8", "pom.xml", "some text");
76  		
77  		GitTestUtils.assertRefNotNull(repository, "enrollment_ks-ap_branches_inactive_KSAP-M8", "enrollment_ks-ap_branches_inactive_KSAP-M8 should exist");
78  		
79  		GitTestUtils.assertPathsExist (repository, "enrollment_ks-ap_branches_inactive_KSAP-M8", Arrays.asList(new String [] {"pom.xml"}));
80  		
81  		// 65430 
82  		runImporter (repository, 65431); 
83  		
84  		GitTestUtils.assertRefNotNull(repository, Constants.R_HEADS + "enrollment_ks-ap_trunk", "expected ks-ap trunk to exist");
85  		
86  		GitTestUtils.assertPathsExist (repository, "enrollment_ks-ap_trunk", Arrays.asList(new String [] {"KSAP", "KSAP-M8", "KSAP/ks-ap-ui/src/main/resources", "KSAP-M8/pom.xml"}));
87  		
88  		GitTestUtils.assertRefNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_inactive_KSAP", "expected ks-ap inactive KSAP to not exist");
89  		
90  		GitTestUtils.assertRefNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_inactive_KSAP-M8", "expected ks-ap inactive KSAP-M8 to not exist");
91  		
92  		runImporter (repository, 65434);
93  		
94  		// we expect nothing to happen because its just a directory add. (not a copy from)
95  		
96  		GitTestUtils.createBranch (repository, Constants.R_HEADS + "enrollment_ks-ap_branches_KSAP-M7", "pom.xml", "some text");
97  		
98  		runImporter (repository, 65435);
99  		
100 		GitTestUtils.assertRefNotNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_inactive_KSAP-M7", "expected ks-ap trunk to exist");
101 		
102 		GitTestUtils.assertPathsExist (repository, "enrollment_ks-ap_branches_inactive_KSAP-M7", Arrays.asList(new String [] {"pom.xml"}));
103 		
104 		GitTestUtils.assertRefNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_KSAP-M7", "expected ks-ap KSAP-M7 to not exist");
105 
106 		
107 		GitTestUtils.createBranch (repository, Constants.R_HEADS + "enrollment_ks-ap_branches_KSAP-archived-2013-09-25", "pom.xml", "some text");
108 		
109 		runImporter (repository, 65437);
110 		
111 		GitTestUtils.assertRefNotNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_inactive_KSAP-archived-2013-09-25", "expected ks-ap braches inactive KSAP-2013-09-25 to exist");
112 		
113 		GitTestUtils.assertRefNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_KSAP-archived-2013-09-25", "expected ks-ap KSAP-archived-2013-09-25 to not exist");
114 		
115 		runImporter (repository, 65439);
116 	
117 		GitTestUtils.assertRefNotNull(repository, Constants.R_HEADS + "enrollment_ks-ap_inactive", "expected ks-ap inactive to exist");
118 		
119 		// assert file does not exist in a specific branch
120 //		assertRefNull(repository, "enrollment, notNullMessage);
121 		
122 		runImporter (repository, 65440);
123 		
124 		GitTestUtils.assertRefNotNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_KSAP", "expected ks-ap branches KSAP to exist");
125 		
126 		GitTestUtils.assertRefNull(repository, Constants.R_HEADS + "enrollment_ks-ap_inactive", "expected ks-ap inactive to not exist");
127 		
128 		runImporter (repository, 65441);
129 		
130 		GitTestUtils.assertRefNotNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_KSAP-M8", "expected ks-ap branches KSAP-M8 to exist");
131 		
132 		GitTestUtils.assertPathsExist (repository, "enrollment_ks-ap_branches_KSAP-M8", Arrays.asList(new String [] {"pom.xml"}));
133 		
134 		// check that the 
135 //		assertRefNull(repository, Constants.R_HEADS + "enrollment_ks-ap_inactive", "expected ks-ap inactive to not exist");
136 		
137 		runImporter (repository, 65442);
138 		
139 		GitTestUtils.assertRefNull(repository, Constants.R_HEADS + "enrollment_ks-ap_trunk", "expected ks-ap trunk to not exist");
140 		
141 		runImporter (repository, 65443);
142 		
143 		GitTestUtils.assertRefNotNull(repository, Constants.R_HEADS + "enrollment_ks-ap_trunk", "expected ks-ap trunk to exist");
144 		
145 		GitTestUtils.assertRefNull(repository, Constants.R_HEADS + "enrollment_ks-ap_branches_KSAP", "expected ks-ap branches KSAP to not exist");
146 		
147 		
148 	}
149 
150 	private void runImporter(Repository repository, long importRevision) throws IOException {
151 		super.runImporter(repository, importRevision, "src/test/resources/ks-r" + importRevision + ".dump.bz2", "https://svn.kuali.org/repos/student", "fake-uuid");
152 	}
153 	
154 
155 }