public void testRoundTrip() throws Exception {
   Adapter a = new Adapter();
   a.setUniqueId(DEFAULT_KEY);
   AdapterStateSummary s1 = new AdapterStateSummary(a);
   AdaptrisMarshaller cm = DefaultMarshaller.getDefaultMarshaller();
   String xml = cm.marshal(s1);
   AdapterStateSummary s2 = (AdapterStateSummary) cm.unmarshal(xml);
   assertRoundtripEquality(s1, s2);
 }
 public void testAdapterStateSummaryAdapterInit() throws Exception {
   Adapter a = new Adapter();
   a.setUniqueId(DEFAULT_KEY);
   a.getChannelList().addChannel(new Channel());
   LifecycleHelper.init(a);
   AdapterStateSummary summary = new AdapterStateSummary(a);
   assertEquals(DEFAULT_KEY, summary.getAdapterState().getKey());
   assertEquals(InitialisedState.class.getName(), summary.getAdapterState().getValue());
   assertNotNull(summary.getLastStopTime());
   assertNull(summary.getLastStartTime());
 }
 public void testAdapterStateSummaryAdapter() throws Exception {
   Adapter a = new Adapter();
   a.setUniqueId(DEFAULT_KEY);
   a.getChannelList().addChannel(new Channel());
   AdapterStateSummary summary = new AdapterStateSummary(a);
   assertNotNull(summary);
   assertNotNull(summary.getLastStopTime());
   assertNull(summary.getLastStartTime());
   assertEquals(DEFAULT_KEY, summary.getAdapterState().getKey());
   assertEquals(ClosedState.class.getName(), summary.getAdapterState().getValue());
   assertEquals(0, summary.getChannelStates().size());
 }
  public void testSetAdapterStateStringComponentState() throws Exception {
    Adapter a = new Adapter();
    a.setUniqueId(DEFAULT_KEY);
    AdapterStateSummary s1 = new AdapterStateSummary(a);
    s1.setAdapterState(DEFAULT_KEY, ClosedState.getInstance());
    assertEquals(DEFAULT_KEY, s1.getAdapterState().getKey());
    assertEquals(ClosedState.getInstance().getClass().getName(), s1.getAdapterState().getValue());
    s1.setAdapterState("", ClosedState.getInstance());
    assertEquals(DEFAULT_KEY, s1.getAdapterState().getKey());
    assertEquals(ClosedState.getInstance().getClass().getName(), s1.getAdapterState().getValue());
    s1.setAdapterState(null, ClosedState.getInstance());
    assertEquals(DEFAULT_KEY, s1.getAdapterState().getKey());
    assertEquals(ClosedState.getInstance().getClass().getName(), s1.getAdapterState().getValue());
    try {
      s1.setAdapterState(DEFAULT_KEY, null);
      fail("Null Component State");
    } catch (IllegalArgumentException expected) {

    }
  }