// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/events/EventOutput.java
// @Value
// public class EventOutput {
// 
//     String type;
//     Long timestamp;
//     String user;
//     Object data;
// 
//     public EventOutput(EventView view) {
//         this.type = view.getType();
//         this.timestamp = view.getTimestamp().getEpochSecond();
//         this.user = view.getData().getUser();
//         this.data = getEventData(view.getData());
//     }
// 
//     /*
//      * For legacy retro-compatibility, look for usage of event.data in: https://github.com/voyages-sncf-technologies/hesperides-gui/tree/master/src/app/event/directives
//      */
//     private static Object getEventData(final UserEvent userEvent) {
//         if (userEvent instanceof ModuleCreatedEvent) {
//             return new ModuleCreatedEventIO((ModuleCreatedEvent) userEvent);
//         }
//         if (userEvent instanceof TemplateCreatedEvent) {
//             return new TemplateCreatedEventIO((TemplateCreatedEvent) userEvent);
//         }
//         if (userEvent instanceof TemplateUpdatedEvent) {
//             return new TemplateUpdatedEventIO((TemplateUpdatedEvent) userEvent);
//         }
//         // For TemplateDeletedEvent, only field used by legacy front is .templateName, so we pass through the event
//         // For many other events (ModuleTechnosUpdatedEvent, techno events...) legacy front was totally bogus and used .platform.platform_name...
//         return userEvent;
//     }
// }


import org.hesperides.core.presentation.io.ModuleIO;
import org.hesperides.core.presentation.io.events.EventOutput;
import org.hesperides.core.presentation.io.platforms.PlatformIO;
import org.hesperides.test.bdd.templatecontainers.TestVersionType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import static org.hesperides.test.bdd.commons.TestContext.getResponseType;
/*
 *
 * This file is part of the Hesperides distribution.
 * (https://github.com/voyages-sncf-technologies/hesperides)
 * Copyright (c) 2016 VSCT.
 *
 * Hesperides is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, version 3.
 *
 * Hesperides is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 *
 */
package org.hesperides.test.bdd.events;



@Component
public class EventClient {

    private final RestTemplate restTemplate;

    public EventClient(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    void getModuleEvents(ModuleIO moduleInput, String tryTo) {
        restTemplate.getForEntity("/events/modules/{name}/{version}/{type}",
// Path: core/presentation/src/main/java/org/hesperides/core/presentation/io/events/EventOutput.java
// @Value
// public class EventOutput {
// 
//     String type;
//     Long timestamp;
//     String user;
//     Object data;
// 
//     public EventOutput(EventView view) {
//         this.type = view.getType();
//         this.timestamp = view.getTimestamp().getEpochSecond();
//         this.user = view.getData().getUser();
//         this.data = getEventData(view.getData());
//     }
// 
//     /*
//      * For legacy retro-compatibility, look for usage of event.data in: https://github.com/voyages-sncf-technologies/hesperides-gui/tree/master/src/app/event/directives
//      */
//     private static Object getEventData(final UserEvent userEvent) {
//         if (userEvent instanceof ModuleCreatedEvent) {
//             return new ModuleCreatedEventIO((ModuleCreatedEvent) userEvent);
//         }
//         if (userEvent instanceof TemplateCreatedEvent) {
//             return new TemplateCreatedEventIO((TemplateCreatedEvent) userEvent);
//         }
//         if (userEvent instanceof TemplateUpdatedEvent) {
//             return new TemplateUpdatedEventIO((TemplateUpdatedEvent) userEvent);
//         }
//         // For TemplateDeletedEvent, only field used by legacy front is .templateName, so we pass through the event
//         // For many other events (ModuleTechnosUpdatedEvent, techno events...) legacy front was totally bogus and used .platform.platform_name...
//         return userEvent;
//     }
// }


// Path: tests/bdd/src/main/java/org/hesperides/test/bdd/events/EventClient.java
import org.hesperides.core.presentation.io.ModuleIO;
import org.hesperides.core.presentation.io.events.EventOutput;
import org.hesperides.core.presentation.io.platforms.PlatformIO;
import org.hesperides.test.bdd.templatecontainers.TestVersionType;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import static org.hesperides.test.bdd.commons.TestContext.getResponseType;

/*
 *
 * This file is part of the Hesperides distribution.
 * (https://github.com/voyages-sncf-technologies/hesperides)
 * Copyright (c) 2016 VSCT.
 *
 * Hesperides is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, version 3.
 *
 * Hesperides is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 *
 */
package org.hesperides.test.bdd.events;



@Component
public class EventClient {

    private final RestTemplate restTemplate;

    public EventClient(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    void getModuleEvents(ModuleIO moduleInput, String tryTo) {
        restTemplate.getForEntity("/events/modules/{name}/{version}/{type}",
                getResponseType(tryTo, EventOutput[].class),