@Test public void testSerialization() throws Exception { TestWelder testWelder = new TestWelder(); testWelder.registrationReference = new MockRegistrationReference(null); TestWelder newTestWelder = WelderTestUtil.transform(testWelder); Assert.assertNull(newTestWelder.registrationReference); Assert.assertFalse(newTestWelder.server); Assert.assertEquals(BaseWelder.State.CREATED, newTestWelder.state); }
@Test public void testDestroty() throws IOException { TestWelder testWelder = new TestWelder(); try { testWelder.destroy(); Assert.fail(); } catch (IllegalStateException ise) { Assert.assertEquals("Unable to destroy a welder with state CREATED", ise.getMessage()); } RegistrationReference registrationReference = new MockRegistrationReference(null); testWelder.registrationReference = registrationReference; testWelder.state = BaseWelder.State.WELDED; testWelder.destroy(); Assert.assertFalse(registrationReference.isValid()); Assert.assertTrue(testWelder._destroyed); Assert.assertEquals(BaseWelder.State.DESTROYED, testWelder.state); }