comparison test/org/tmatesoft/hg/test/TestStatus.java @ 454:36fd1fd06492

oth.util.Status renamed to Outcome as the noun is too overloaded, especially in scm
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 13 Jun 2012 21:07:39 +0200
parents 6865eb742883
children c95cd5994ba2
comparison
equal deleted inserted replaced
453:7b883bf03b14 454:36fd1fd06492
46 import org.tmatesoft.hg.repo.HgLookup; 46 import org.tmatesoft.hg.repo.HgLookup;
47 import org.tmatesoft.hg.repo.HgRepository; 47 import org.tmatesoft.hg.repo.HgRepository;
48 import org.tmatesoft.hg.repo.HgStatusCollector; 48 import org.tmatesoft.hg.repo.HgStatusCollector;
49 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; 49 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector;
50 import org.tmatesoft.hg.util.Path; 50 import org.tmatesoft.hg.util.Path;
51 import org.tmatesoft.hg.util.Status; 51 import org.tmatesoft.hg.util.Outcome;
52 52
53 /** 53 /**
54 * 54 *
55 * @author Artem Tikhomirov 55 * @author Artem Tikhomirov
56 * @author TMate Software Ltd. 56 * @author TMate Software Ltd.
179 } 179 }
180 180
181 static class StatusCollector implements HgStatusHandler { 181 static class StatusCollector implements HgStatusHandler {
182 private final Map<Kind, List<Path>> kind2names = new TreeMap<Kind, List<Path>>(); 182 private final Map<Kind, List<Path>> kind2names = new TreeMap<Kind, List<Path>>();
183 private final Map<Path, List<Kind>> name2kinds = new TreeMap<Path, List<Kind>>(); 183 private final Map<Path, List<Kind>> name2kinds = new TreeMap<Path, List<Kind>>();
184 private final Map<Path, Status> name2error = new LinkedHashMap<Path, Status>(); 184 private final Map<Path, Outcome> name2error = new LinkedHashMap<Path, Outcome>();
185 private final Map<Path, Path> new2oldName = new LinkedHashMap<Path, Path>(); 185 private final Map<Path, Path> new2oldName = new LinkedHashMap<Path, Path>();
186 186
187 public void status(HgStatus s) { 187 public void status(HgStatus s) {
188 List<Path> l = kind2names.get(s.getKind()); 188 List<Path> l = kind2names.get(s.getKind());
189 if (l == null) { 189 if (l == null) {
199 name2kinds.put(s.getPath(), k = new LinkedList<Kind>()); 199 name2kinds.put(s.getPath(), k = new LinkedList<Kind>());
200 } 200 }
201 k.add(s.getKind()); 201 k.add(s.getKind());
202 } 202 }
203 203
204 public void error(Path file, Status s) { 204 public void error(Path file, Outcome s) {
205 name2error.put(file, s); 205 name2error.put(file, s);
206 } 206 }
207 207
208 public List<Path> get(Kind k) { 208 public List<Path> get(Kind k) {
209 List<Path> rv = kind2names.get(k); 209 List<Path> rv = kind2names.get(k);
213 public List<Kind> get(Path p) { 213 public List<Kind> get(Path p) {
214 List<Kind> rv = name2kinds.get(p); 214 List<Kind> rv = name2kinds.get(p);
215 return rv == null ? Collections.<Kind> emptyList() : rv; 215 return rv == null ? Collections.<Kind> emptyList() : rv;
216 } 216 }
217 217
218 public Map<Path, Status> getErrors() { 218 public Map<Path, Outcome> getErrors() {
219 return name2error; 219 return name2error;
220 } 220 }
221 221
222 public HgStatusCollector.Record asStatusRecord() { 222 public HgStatusCollector.Record asStatusRecord() {
223 HgStatusCollector.Record rv = new HgStatusCollector.Record(); 223 HgStatusCollector.Record rv = new HgStatusCollector.Record();
603 cmd.all(); 603 cmd.all();
604 StatusCollector sc = new StatusCollector(); 604 StatusCollector sc = new StatusCollector();
605 cmd.execute(sc); 605 cmd.execute(sc);
606 // shall pass without exception 606 // shall pass without exception
607 // 607 //
608 for (Map.Entry<Path, Status> e : sc.getErrors().entrySet()) { 608 for (Map.Entry<Path, Outcome> e : sc.getErrors().entrySet()) {
609 System.out.printf("%s : (%s %s)\n", e.getKey(), e.getValue().getKind(), e.getValue().getMessage()); 609 System.out.printf("%s : (%s %s)\n", e.getKey(), e.getValue().getKind(), e.getValue().getMessage());
610 } 610 }
611 assertTrue(sc.getErrors().isEmpty()); 611 assertTrue(sc.getErrors().isEmpty());
612 } 612 }
613 613
634 cmd.all(); 634 cmd.all();
635 StatusCollector sc = new StatusCollector(); 635 StatusCollector sc = new StatusCollector();
636 cmd.execute(sc); 636 cmd.execute(sc);
637 // shall pass without exception 637 // shall pass without exception
638 // 638 //
639 for (Map.Entry<Path, Status> e : sc.getErrors().entrySet()) { 639 for (Map.Entry<Path, Outcome> e : sc.getErrors().entrySet()) {
640 System.out.printf("%s : (%s %s)\n", e.getKey(), e.getValue().getKind(), e.getValue().getMessage()); 640 System.out.printf("%s : (%s %s)\n", e.getKey(), e.getValue().getKind(), e.getValue().getMessage());
641 } 641 }
642 assertTrue(sc.getErrors().isEmpty()); 642 assertTrue(sc.getErrors().isEmpty());
643 } 643 }
644 644