@Test
  public void testGetComponentConfiguration() {
    final PrincipalModel principalModel = mock(PrincipalModel.class);
    final String objectTemplateCode = "mockTemplateCode";
    final String code = "mockCode";

    when(cockpitConfigurationDao.findComponentConfigurations(
            principalModel, objectTemplateCode, code))
        .thenReturn(componentConfigurationModels);

    try {
      cockpitConfigurationService.getComponentConfiguration(
          principalModel, objectTemplateCode, code);
      Assert.fail("Should throw exception!");
    } catch (final AmbiguousIdentifierException aie) {
      // OK
    }

    componentConfigurationModels.remove(1);

    final CockpitUIComponentConfigurationModel resultModel =
        cockpitConfigurationService.getComponentConfiguration(
            principalModel, objectTemplateCode, code);

    Assert.assertNotNull(resultModel);
    Assert.assertEquals("Wrong configuration returned", "model1Code", resultModel.getCode());
  }
  @Test
  public void testGetDedicatedComponentConfigurationsForPrincipal() {
    final PrincipalModel principalModel = mock(PrincipalModel.class);

    when(cockpitConfigurationDao.findDedicatedComponentConfigurationsByPrincipal(principalModel))
        .thenReturn(componentConfigurationModels);

    final List<CockpitUIComponentConfigurationModel> resultModels =
        cockpitConfigurationService.getDedicatedComponentConfigurationsForPrincipal(principalModel);

    Assert.assertEquals("Got different number of results", 2, resultModels.size());
  }
  @Before
  public void setUp() {
    MockitoAnnotations.initMocks(this);

    cockpitConfigurationService = new DefaultCockpitConfigurationService();
    cockpitConfigurationService.setCockpitConfigurationDao(cockpitConfigurationDao);

    componentConfigurationModels = new ArrayList<CockpitUIComponentConfigurationModel>(2);
    model1 = mock(CockpitUIComponentConfigurationModel.class);
    when(model1.getCode()).thenReturn("model1Code");
    model2 = mock(CockpitUIComponentConfigurationModel.class);
    componentConfigurationModels.add(0, model1);
    componentConfigurationModels.add(1, model2);
  }