DtoConverter { public static SystemStatusChangedEventDto asDto(SystemStatusChangedEvent event) { SystemStatusChangedEventDto dto = DtoFactory.newDto(SystemStatusChangedEventDto.class); dto.setType(event.getType()); dto.setStatus(event.getStatus()); dto.setPrevStatus(event.getPrevStatus()); return dto; } private  DtoConverter(); static SystemStatusChangedEventDto asDto(SystemStatusChangedEvent event); static SystemServiceEventDto asDto(SystemServiceEvent event); static SystemServiceItemStoppedEventDto asDto(SystemServiceItemStoppedEvent event); static SystemEventDto asDto(SystemEvent event);  }
@Test public void convertsSystemStatusChangedEvent() { SystemStatusChangedEvent event = new SystemStatusChangedEvent(RUNNING, PREPARING_TO_SHUTDOWN); SystemStatusChangedEventDto dto = DtoConverter.asDto(event); assertEquals(dto.getType(), EventType.STATUS_CHANGED); assertEquals(dto.getPrevStatus(), event.getPrevStatus()); assertEquals(dto.getStatus(), event.getStatus()); }
@Test public void convertsSystemServiceStoppingEvent() { StoppingSystemServiceEvent event = new StoppingSystemServiceEvent("service1"); SystemServiceEventDto dto = DtoConverter.asDto(event); assertEquals(dto.getType(), EventType.STOPPING_SERVICE); assertEquals(dto.getService(), event.getServiceName()); }
@Test public void convertsSystemServiceStoppedEvent() { SystemServiceStoppedEvent event = new SystemServiceStoppedEvent("service1"); SystemServiceEventDto dto = DtoConverter.asDto(event); assertEquals(dto.getType(), EventType.SERVICE_STOPPED); assertEquals(dto.getService(), event.getServiceName()); }
@Test public void convertsSystemServiceItemStoppedEvent() { SystemServiceItemStoppedEvent event = new SystemServiceItemStoppedEvent("service1", "workspace1", 3, 5); SystemServiceItemStoppedEventDto dto = DtoConverter.asDto(event); assertEquals(dto.getType(), EventType.SERVICE_ITEM_STOPPED); assertEquals(dto.getService(), event.getServiceName()); assertEquals(dto.getItem(), event.getItem()); assertEquals(dto.getCurrent(), event.getCurrent()); assertEquals(dto.getTotal(), event.getTotal()); }