package org.osiam.client;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.osiam.resources.scim.User;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;

import com.github.springtestdbunit.DbUnitTestExecutionListener;
import com.github.springtestdbunit.annotation.DatabaseOperation;
import com.github.springtestdbunit.annotation.DatabaseSetup;
import com.github.springtestdbunit.annotation.DatabaseTearDown;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/context.xml")
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class,
        DbUnitTestExecutionListener.class })
@DatabaseTearDown(value = "/database_tear_down.xml", type = DatabaseOperation.DELETE_ALL)
@DatabaseSetup(value = "/database_seeds/SearchByExtensionIT/extensions.xml")
public class EmptyDateIT extends AbstractIntegrationTestBase {
    
    @Test
    public void replace_user_with_empty_date_extension_fail() {
        User user = oConnector.getUser("df7d06b2-b6ee-42b1-8c1b-4bd1176cc8d4", accessToken);
        user.getExtension("extension").addOrUpdateField("birthday", "");
        user.getExtension("extension").addOrUpdateField("gender", "");
        
        User replacedUser = oConnector.replaceUser(user, accessToken);
        
        assertThat(replacedUser.getExtension("extension").isFieldPresent("birthday"), is(equalTo(false)));
        assertThat(replacedUser.getExtension("extension").isFieldPresent("gender"), is(equalTo(false)));
    }

}
@@ -1471,79 +1471,8 @@
 %22);%0A
-        user.getExtension(%22extension%22).addOrUpdateField(%22gender%22, %22%22);%0A
     
@@ -1667,113 +1667,8 @@
 ));%0A
-        assertThat(replacedUser.getExtension(%22extension%22).isFieldPresent(%22gender%22), is(equalTo(false)));%0A
     

reset test to original state