@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());
  }
  @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);
  }