/*
 * Copyright: 2009, Teleal GmbH, Switzerland
 *
 * This program 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 or later of the License.
 *
 * This program 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.teleal.cling.test.support.avtransport;

import static org.testng.Assert.assertEquals;

/**
 *
 */
public class AVTransportTransitionsTest {
/*
    @Test
    public void setAVTransportURITest() throws Exception {

        UpnpServiceImpl router = new UpnpServiceImpl(new TestModel.NetworkDisabledRouterConfiguration());

        LocalDevice device = createTestDevice();
        final AVTransport transport = createTestTransport();

        AVTransportService service =
                new AVTransportService(device, AVTransportStateMachine.class, NoMediaPresent.class, AVTransport.class) {
                    protected AVTransport createTransport(long id) {
                        return transport;
                    }
                };

        service.bind();
        router.addDevice(device);

        // Current state
        ActionInvocation invocation = new ActionInvocation(service.getAction("GetDeviceCapabilities"));
        invocation.getInput().addValue(new UnsignedIntegerFourBytes(0));
        service.execute(invocation);
        assert invocation.getFailure() == null;
        assertEquals(invocation.getOutput().getValues()[0].toString(), "NETWORK");
        assertEquals(invocation.getOutput().getValues()[1].toString(), "NOT_IMPLEMENTED");
        assertEquals(invocation.getOutput().getValues()[2].toString(), "NOT_IMPLEMENTED");

        // Change state
        invocation = new ActionInvocation(service.getAction("SetAVTransportURI"));
        invocation.getInput().addValue(new UnsignedIntegerFourBytes(0));
        invocation.getInput().addValue("http://foo.bar/baz.mpeg");
        invocation.getInput().addValue("");
        service.execute(invocation);
        assert invocation.getFailure() == null;

        // Test internal state
        assertEquals(transport.getMediaInfo().getCurrentURI(), "http://foo.bar/baz.mpeg");
        assertEquals(transport.getMediaInfo().getCurrentURIMetaData(), "");
        String[] availableStates = service.getCurrentTransportActions(new UnsignedIntegerFourBytes(0)).split(",");
        assert availableStates.length == 2;
        assert (availableStates[0].equals(TransportState.ACTION_STOP) || availableStates[1].equals(TransportState.ACTION_STOP));
        assert (availableStates[0].equals(TransportState.ACTION_PLAY) || availableStates[1].equals(TransportState.ACTION_PLAY));

        // Test external state
        invocation = new ActionInvocation(service.getAction("GetMediaInfo"));
        invocation.getInput().addValue(new UnsignedIntegerFourBytes(0));
        service.execute(invocation);
        assert invocation.getFailure() == null;
        assertEquals(invocation.getOutput().getValues()[0].toString(), "0");
        assertEquals(invocation.getOutput().getValues()[1].toString(), "00:00:00");
        assertEquals(invocation.getOutput().getValues()[2].toString(), "http://foo.bar/baz.mpeg");
        assertEquals(invocation.getOutput().getValues()[3].toString(), "");
        assertEquals(invocation.getOutput().getValues()[4].toString(), "NOT_IMPLEMENTED");
        assertEquals(invocation.getOutput().getValues()[5].toString(), "NOT_IMPLEMENTED");
        assertEquals(invocation.getOutput().getValues()[6].toString(), "NONE");
        assertEquals(invocation.getOutput().getValues()[7].toString(), "NOT_IMPLEMENTED");
        assertEquals(invocation.getOutput().getValues()[8].toString(), "NOT_IMPLEMENTED");

        invocation = new ActionInvocation(service.getAction("GetTransportInfo"));
        invocation.getInput().addValue(new UnsignedIntegerFourBytes(0));
        service.execute(invocation);
        assert invocation.getFailure() == null;
        assertEquals(invocation.getOutput().getValues()[0].toString(), "STOPPED");
        assertEquals(invocation.getOutput().getValues()[1].toString(), "OK");
        assertEquals(invocation.getOutput().getValues()[2].toString(), "1");

        invocation = new ActionInvocation(service.getAction("GetPositionInfo"));
        invocation.getInput().addValue(new UnsignedIntegerFourBytes(0));
        service.execute(invocation);
        assert invocation.getFailure() == null;
        assertEquals(invocation.getOutput().getValues()[0].toString(), "1");
        assertEquals(invocation.getOutput().getValues()[1].toString(), "00:00:00");
        assertEquals(invocation.getOutput().getValues()[2].toString(), "NOT_IMPLEMENTED");
        assertEquals(invocation.getOutput().getValues()[3].toString(), "http://foo.bar/baz.mpeg");
        assertEquals(invocation.getOutput().getValues()[4].toString(), "00:00:00");
        assertEquals(invocation.getOutput().getValues()[5].toString(), "00:00:00");
        assertEquals(invocation.getOutput().getValues()[6].toString(), Integer.toString(Integer.MAX_VALUE));
        assertEquals(invocation.getOutput().getValues()[7].toString(), Integer.toString(Integer.MAX_VALUE));

        invocation = new ActionInvocation(service.getAction("GetTransportSettings"));
        invocation.getInput().addValue(new UnsignedIntegerFourBytes(0));
        service.execute(invocation);
        assert invocation.getFailure() == null;
        assertEquals(invocation.getOutput().getValues()[0].toString(), "NORMAL");
        assertEquals(invocation.getOutput().getValues()[1].toString(), "NOT_IMPLEMENTED");

        invocation = new ActionInvocation(service.getAction("GetCurrentTransportActions"));
        invocation.getInput().addValue(new UnsignedIntegerFourBytes(0));
        service.execute(invocation);
        assert invocation.getFailure() == null;
        availableStates = invocation.getOutput().getValues()[0].toString().split(",");
        assert (availableStates[0].equals(TransportState.ACTION_STOP) || availableStates[1].equals(TransportState.ACTION_STOP));
        assert (availableStates[0].equals(TransportState.ACTION_PLAY) || availableStates[1].equals(TransportState.ACTION_PLAY));
    }

    protected AVTransport createTestTransport() {
        return new AVTransport(new StorageMedium[]{StorageMedium.NETWORK});
    }


    protected LocalDevice createTestDevice() {
        LocalDevice device = new LocalDevice(new UDN(UUID.randomUUID()));
        device.setDeviceType(new UDADeviceType("MediaRenderer", 1));
        device.setFriendlyName("VLC Media Renderer");
        device.setManufacturer("Teleal");
        device.setModelName("VLC Media Renderer");
        device.setModelNumber("v1.0alpha1");
        return device;
    }
    */
}
