    @Test
    public void testCreateNewComponentState() {

        String componentId = "componentId";
        ComponentType componentType = ComponentType.APP;
        Criteria mockCriteria = mock(Criteria.class);
        DbSession mockSession = mock(DbSession.class);
        when(sessionFactory.getCurrentSession()).thenReturn(mockSession);
        when(mockSession.createCriteria(ComponentState.class)).thenReturn(mockCriteria);
        when(mockCriteria.uniqueResult()).thenReturn(null);

        allComponentsState.setComponentState(componentId, componentType, true);

        ArgumentCaptor<ComponentState> componentStateArgumentCaptor = ArgumentCaptor.forClass(ComponentState.class);
        verify(mockSession).saveOrUpdate(componentStateArgumentCaptor.capture());
        ComponentState componentState = componentStateArgumentCaptor.getValue();
        assertEquals(null, componentState.getId());
        assertEquals(componentId, componentState.getComponentId());
        assertEquals(componentType, componentState.getComponentType());
        assertEquals(true, (boolean) componentState.getEnabled());
    }