@Test
	public void testProfileCrudUsingCard() throws BeanstreamApiException {
		String profileId = null;
		try {
			Address billing = getTestCardValidAddress();
			Card card = getTestCard();
			// test create profile
			ProfileResponse createdProfile = beanstream.profiles()
					.createProfile(card, billing);
			profileId = createdProfile.getId();
			Assert.assertNotNull(
					"Test failed because it should create the profile and return a valid id",
					profileId);

			// test get profile by id
			PaymentProfile paymentProfile = beanstream.profiles()
					.getProfileById(profileId);
			Assert.assertEquals(
					"billing address assinged does not matches with the one sent at creation time",
					paymentProfile.getBilling(), billing);
			Assert.assertNotNull("Credit card was not in the response",
					paymentProfile.getCard());
			Assert.assertTrue("The default lenguage should be english","en".equals(paymentProfile.getLanguage()));
			
			// update the profile to francais
			paymentProfile.setLanguage("fr");
			paymentProfile.setComments("test updating profile sending billing info only");
			// update profile
			beanstream.profiles().updateProfile(paymentProfile);

			// refresh the updated profile
			paymentProfile = beanstream.profiles().getProfileById(profileId);
			
			Assert.assertEquals("Language was updated to Francais",
					paymentProfile.getLanguage(), "fr");
			
			// delete the payment profile
			beanstream.profiles().deleteProfileById(profileId);
			try {
				beanstream.profiles().getProfileById(profileId);
				Assert.fail("This profile was deleted, therefore should throw an exception");
			} catch (BeanstreamApiException e) {
				profileId = null;
			}
		} catch (BeanstreamApiException ex) {
			Assert.fail("Test can not continue, "+ex.getMessage());
		} catch (Exception ex) {
			Assert.fail("unexpected exception occur, test can not continue");
		} finally {
			if (profileId != null) {
				ProfileResponse response = beanstream.profiles()
						.deleteProfileById(profileId);
			}
		}

	}