@@ -0,0 +1,2633 @@
+package org.jtalks.poulpe.validation.unique;%0A%0Aimport static org.testng.Assert.*;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.Map.Entry;%0Aimport java.util.Set;%0A%0Aimport org.jtalks.poulpe.model.dao.hibernate.ObjectsFactory;%0Aimport org.jtalks.poulpe.model.entity.Component;%0Aimport org.jtalks.poulpe.model.entity.ComponentType;%0Aimport org.testng.annotations.BeforeClass;%0Aimport org.testng.annotations.Test;%0A%0A/**%0A * @author Alexey Grigorev%0A */%0Apublic class EntityWrapperTest %7B%0A%0A    private long id = 10;%0A    private EntityWrapper wrapper;%0A    private Component component;%0A%0A    @BeforeClass%0A    public void beforeClass() %7B%0A        component = ObjectsFactory.createComponent(ComponentType.ARTICLE);%0A        component.setId(id);%0A%0A        wrapper = new EntityWrapper(component);%0A    %7D%0A%0A    @Test%0A    public void getEntityI1d() %7B%0A        assertEquals(wrapper.getEntityId(), id);%0A    %7D%0A%0A    @Test%0A    public void getEntityClass() %7B%0A        assertEquals(wrapper.getEntityClass(), Component.class);%0A    %7D%0A%0A    @Test%0A    public void getErrorMessage() %7B%0A        String errorMessage = wrapper.getErrorMessage(%22name%22);%0A        assertEquals(errorMessage, Component.NOT_UNIQUE_NAME);%0A    %7D%0A%0A    @Test%0A    public void getNameValue() %7B%0A        Object actual = wrapper.getValue(%22name%22);%0A        String expected = component.getName();%0A        assertEquals(actual, expected);%0A    %7D%0A%0A    @Test%0A    public void getComponentTypeValue() %7B%0A        Object actual = wrapper.getValue(%22componentType%22);%0A        ComponentType expected = component.getComponentType();%0A        assertEquals(actual, expected);%0A    %7D%0A%0A    @Test%0A    public void getProperties() %7B%0A        Set%3CEntry%3CString, Object%3E%3E properties = wrapper.getProperties();%0A%0A        Map%3CString, Object%3E result = toMap(properties);%0A%0A        assertEquals(result.size(), 2);%0A        assertEquals(component.getName(), result.get(%22name%22));%0A        assertEquals(component.getComponentType(), result.get(%22componentType%22));%0A    %7D%0A%0A    @Test%0A    public void nullsFiltered() %7B%0A        component.setComponentType(null);%0A        wrapper = new EntityWrapper(component);%0A%0A        Set%3CEntry%3CString, Object%3E%3E properties = wrapper.getProperties();%0A        Map%3CString, Object%3E result = toMap(properties);%0A%0A        assertEquals(result.size(), 1);%0A        assertEquals(component.getName(), result.get(%22name%22));%0A        assertNull(component.getComponentType());%0A    %7D%0A%0A    public static %3CK, V%3E Map%3CK, V%3E toMap(Set%3CEntry%3CK, V%3E%3E properties) %7B%0A        Map%3CK, V%3E m = new HashMap%3CK, V%3E();%0A%0A        for (Entry%3CK, V%3E e : properties) %7B%0A            m.put(e.getKey(), e.getValue());%0A        %7D%0A%0A        return m;%0A    %7D%0A%0A%7D%0A

test for EntityWrapper