/*
 * CODENVY CONFIDENTIAL
 * __________________
 *
 *  [2012] - [2014] Codenvy, S.A.
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Codenvy S.A. and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Codenvy S.A.
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Codenvy S.A..
 */
package com.codenvy.im.request;


import com.codenvy.im.artifacts.ArtifactFactory;
import com.codenvy.im.artifacts.CDECArtifact;
import com.codenvy.im.exceptions.ArtifactNotFoundException;
import com.codenvy.im.service.UserCredentials;
import com.codenvy.im.utils.Version;

import org.testng.Assert;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

/** @author Dmytro Nochevnov */
public class TestRequest {

    @Test
    public void testRequest() throws Exception {
        Request testRequest = new Request()
                .setArtifactName("cdec")
                .setVersion("1.0.1")
                .setUserCredentials(new UserCredentials("test token", "test account id"));

        assertEquals(testRequest.getArtifact(), ArtifactFactory.createArtifact(CDECArtifact.NAME));
        assertEquals(testRequest.getVersion(), Version.valueOf("1.0.1"));
        Assert.assertNotNull(testRequest.getUserCredentials());
        assertEquals(testRequest.getAccessToken(), "test token");
        assertEquals(testRequest.getAccountId(), "test account id");
    }

    @Test(expectedExceptions = ArtifactNotFoundException.class)
    public void testRequestErrorIfArtifactUnknown() throws Exception {
        Request testRequest = new Request()
                .setArtifactName("cdecxxx")
                .setVersion("1.0.1");

        testRequest.getArtifact();
    }

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testRequestErrorIfVersionInvalid() throws Exception {
        Request testRequest = new Request()
                .setArtifactName("cdec")
                .setVersion("00.1.1");

        testRequest.getVersion();
    }
}

@@ -1014,16 +1014,60 @@
 tEquals;
+%0Aimport static org.testng.Assert.assertTrue;
 %0A%0A/** @a
@@ -2374,11 +2374,609 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testEquals() throws Exception %7B%0A        Request request1 = new Request()%0A                .setArtifactName(%22cdec%22)%0A                .setVersion(%221.0.1%22)%0A                .setUserCredentials(new UserCredentials(%22test token%22, %22test account id%22));%0A%0A        Request request2 = new Request()%0A                .setArtifactName(%22cdec%22)%0A                .setVersion(%221.0.1%22)%0A                .setUserCredentials(new UserCredentials(%22test token%22, %22test account id%22));%0A%0A        assertTrue(request1.equals(request2));%0A        assertEquals(request1.hashCode(), request2.hashCode());%0A    %7D
 %0A%7D%0A

Implement commands to install CDEC on single node with puppet master