// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
// 
// 	/** This flag will be set if there was a deserialization error */
// 	public boolean deserialize_error = false;
// 
// 	/** the actual response data */
// 	public T data;
// }


import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserLinkEditResponse;
import net.swisstech.bitly.model.v3.UserLinkSaveResponse;
import org.joda.time.DateTime;
import org.testng.annotations.Test;
/*
 * Copyright (c) Patrick Huber (gmail: stackmagic)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.swisstech.bitly.test;



/**
 * <p>
 * Please see the bit.ly documentation for the <a href="http://dev.bitly.com/links.html#v3_user_link_save">/v3/user/link_save</a> request.
 * </p>
 * @author Patrick Huber (gmail: stackmagic)
 */
public class UserLinkSaveIntegrationTest extends AbstractBitlyClientIntegrationTest {

	@Test
	public void callUserLinkSaveExistingLink() {
		// must have a unique link and so we add milliseconds
		Response<UserLinkSaveResponse> resp = getClient().userLinkSave() //
			.setLongUrl("https://www.example.com/bitly-api-client-test") //
			.setTitle("example user link save (existing)") //
			.setNote("testing link save (existing)") //
			.setPrivate(true) //
			.setUserTs(DateTime.now()) //
			.call();

		printAndVerify(resp, UserLinkSaveResponse.class, 304, "LINK_ALREADY_EXISTS");

// Path: src/main/java/net/swisstech/bitly/model/Response.java
// public class Response<T> extends ResponsePartial {
// 
// 	/** This flag will be set if there was a deserialization error */
// 	public boolean deserialize_error = false;
// 
// 	/** the actual response data */
// 	public T data;
// }


// Path: src/intTest/java/net/swisstech/bitly/test/UserLinkSaveIntegrationTest.java
import static net.swisstech.bitly.test.util.TestUtil.printAndVerify;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import net.swisstech.bitly.model.Response;
import net.swisstech.bitly.model.v3.UserLinkEditResponse;
import net.swisstech.bitly.model.v3.UserLinkSaveResponse;
import org.joda.time.DateTime;
import org.testng.annotations.Test;

/*
 * Copyright (c) Patrick Huber (gmail: stackmagic)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.swisstech.bitly.test;



/**
 * <p>
 * Please see the bit.ly documentation for the <a href="http://dev.bitly.com/links.html#v3_user_link_save">/v3/user/link_save</a> request.
 * </p>
 * @author Patrick Huber (gmail: stackmagic)
 */
public class UserLinkSaveIntegrationTest extends AbstractBitlyClientIntegrationTest {

	@Test
	public void callUserLinkSaveExistingLink() {
		// must have a unique link and so we add milliseconds
		Response<UserLinkSaveResponse> resp = getClient().userLinkSave() //
			.setLongUrl("https://www.example.com/bitly-api-client-test") //
			.setTitle("example user link save (existing)") //
			.setNote("testing link save (existing)") //
			.setPrivate(true) //
			.setUserTs(DateTime.now()) //
			.call();

		printAndVerify(resp, UserLinkSaveResponse.class, 304, "LINK_ALREADY_EXISTS");

		assertEquals(resp.data.link_save.aggregate_link, "http://bit.ly/MtVsf2");