MCPcopy Create free account
hub / github.com/Neop/mudmap2 / testRemovePath

Method testRemovePath

src/test/java/mudmap2/backend/PlaceTest.java:478–521  ·  view source on GitHub ↗

Test of removePath method, of class Place.

()

Source from the content-addressed store, hash-verified

476 * Test of removePath method, of class Place.
477 */
478 @Test
479 public void testRemovePath() {
480 System.out.println("removePath");
481
482 Place instance = new Place("MyPlace", 1, 1, layer);
483 Place place = new Place("Another place", 1, 2, layer);
484
485 // path does not exist in place
486 try {
487 instance.removePath(new Path(instance, "n", place, "s"));
488 } catch(Exception e){
489 // don't throw if path has already been removed
490 fail();
491 }
492
493 // test null
494 try {
495 instance.removePath(null);
496 fail();
497 } catch(Exception e){
498 // expected
499 }
500
501 Path p1 = new Path(instance, "n", place, "s");
502 Path p2 = new Path(place, "n", instance, "s");
503 instance.connectPath(p1);
504 instance.connectPath(p2);
505
506 HashSet<Path> result = instance.getPaths(place);
507 assertEquals(2, result.size());
508 assertTrue(result.contains(p1));
509 assertTrue(result.contains(p2));
510
511 instance.removePath(p1);
512 result = instance.getPaths(place);
513 assertEquals(1, result.size());
514 assertFalse(result.contains(p1));
515 assertTrue(result.contains(p2));
516
517 instance.removePath(p2);
518 result = instance.getPaths(place);
519 assertEquals(0, result.size());
520 assertFalse(result.contains(p2));
521 }
522
523 /**
524 * Test of connectPath method, of class Place.

Callers

nothing calls this directly

Calls 4

removePathMethod · 0.95
connectPathMethod · 0.95
getPathsMethod · 0.95
containsMethod · 0.65

Tested by

no test coverage detected