Test of putPlace method, of class Layer. @throws java.lang.Exception
()
| 451 | * @throws java.lang.Exception |
| 452 | */ |
| 453 | @Test |
| 454 | public void testPut_LayerElement() throws Exception { |
| 455 | System.out.println("put"); |
| 456 | |
| 457 | Layer instance = new Layer(world); |
| 458 | Layer other = world.getNewLayer(); |
| 459 | |
| 460 | try { |
| 461 | int x = 0; |
| 462 | int y = 0; |
| 463 | Place element = new Place("MyPlace", x, y, instance); |
| 464 | instance.put(element); |
| 465 | assertEquals(element, instance.get(x, y)); |
| 466 | } catch (Layer.PlaceNotInsertedException ex) { |
| 467 | Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex); |
| 468 | fail(ex.getMessage()); |
| 469 | } |
| 470 | |
| 471 | try { |
| 472 | int x = -5; |
| 473 | int y = -2; |
| 474 | Place element = new Place("MyPlace", x, y, instance); |
| 475 | instance.put(element); |
| 476 | assertEquals(element, instance.get(x, y)); |
| 477 | } catch (Layer.PlaceNotInsertedException ex) { |
| 478 | Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex); |
| 479 | fail(ex.getMessage()); |
| 480 | } |
| 481 | |
| 482 | try { |
| 483 | int x = 3; |
| 484 | int y = 9; |
| 485 | Place element = new Place("MyPlace", x, y, instance); |
| 486 | instance.put(element); |
| 487 | assertEquals(element, instance.get(x, y)); |
| 488 | } catch (Layer.PlaceNotInsertedException ex) { |
| 489 | Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex); |
| 490 | fail(ex.getMessage()); |
| 491 | } |
| 492 | |
| 493 | // try to put a place to an occupied position |
| 494 | try { |
| 495 | int x = 0; |
| 496 | int y = 0; |
| 497 | Place element = new Place("MyPlace", x, y, instance); |
| 498 | instance.put(element); |
| 499 | fail(); |
| 500 | } catch (Layer.PlaceNotInsertedException ex) { |
| 501 | // expected |
| 502 | } |
| 503 | |
| 504 | // move place to a different layer |
| 505 | try { |
| 506 | // put on other layer |
| 507 | int x = 3; |
| 508 | int y = 7; |
| 509 | Place element = new Place("MyPlace", x, y, instance); |
| 510 | other.put(element, x, y); |
nothing calls this directly
no test coverage detected