@Test
public void updateFactMappingInstance() {

    final int INDEX = 0;
    final String ALIAS_1 = "ALIAS_1";
    final String ALIAS_2 = "ALIAS_2";
    FactMapping factMappingReference = mock(FactMapping.class);
    FactMapping factMappingToCheck = mock(FactMapping.class);
    FactIdentifier factIdentifier1 = mock(FactIdentifier.class);
    FactIdentifier factIdentifier2 = mock(FactIdentifier.class);
    // Should execute the if in the first if
    when(factMappingReference.getFactIdentifier()).thenReturn(FactIdentifier.EMPTY);
    when(factMappingToCheck.getFactIdentifier()).thenReturn(FactIdentifier.EMPTY);
    when(factMappingReference.getFactAlias()).thenReturn(ALIAS_1);
    when(factMappingToCheck.getFactAlias()).thenReturn(ALIAS_1);
    when(simulationDescriptorMock.getFactMappingByIndex(INDEX)).thenReturn(factMappingToCheck);
    abstractScesimGridModelSpy.updateFactMapping(simulationDescriptorMock, factMappingReference, INDEX, MULTIPART_VALUE, ScenarioHeaderMetaData.MetadataType.INSTANCE);
    verify(informationHeaderMetaDataMock, times(1)).setTitle(eq(MULTIPART_VALUE));
    verify(factMappingToCheck, times(1)).setFactAlias(eq(MULTIPART_VALUE));
    reset(informationHeaderMetaDataMock);
    reset(factMappingToCheck);
    // Should not execute the if in the first if
    when(factMappingToCheck.getFactAlias()).thenReturn(ALIAS_2);
    abstractScesimGridModelSpy.updateFactMapping(simulationDescriptorMock, factMappingReference, INDEX, MULTIPART_VALUE, ScenarioHeaderMetaData.MetadataType.INSTANCE);
    verify(informationHeaderMetaDataMock, never()).setTitle(eq(MULTIPART_VALUE));
    verify(factMappingToCheck, never()).setFactAlias(eq(MULTIPART_VALUE));
    reset(informationHeaderMetaDataMock);
    reset(factMappingToCheck);
    // Should not execute the if in the first if
    when(factMappingReference.getFactIdentifier()).thenReturn(factIdentifier1);
    when(factMappingToCheck.getFactAlias()).thenReturn(ALIAS_1);
    abstractScesimGridModelSpy.updateFactMapping(simulationDescriptorMock, factMappingReference, INDEX, MULTIPART_VALUE, ScenarioHeaderMetaData.MetadataType.INSTANCE);
    verify(informationHeaderMetaDataMock, never()).setTitle(eq(MULTIPART_VALUE));
    verify(factMappingToCheck, never()).setFactAlias(eq(MULTIPART_VALUE));
    reset(informationHeaderMetaDataMock);
    reset(factMappingToCheck);
    // Should execute the second if
    when(factMappingToCheck.getFactIdentifier()).thenReturn(factIdentifier1);
    abstractScesimGridModelSpy.updateFactMapping(simulationDescriptorMock, factMappingReference, INDEX, MULTIPART_VALUE, ScenarioHeaderMetaData.MetadataType.INSTANCE);
    verify(informationHeaderMetaDataMock, times(1)).setTitle(eq(MULTIPART_VALUE));
    verify(factMappingToCheck, times(1)).setFactAlias(eq(MULTIPART_VALUE));
    reset(informationHeaderMetaDataMock);
    reset(factMappingToCheck);
    // Should not execute the second if
    when(factMappingToCheck.getFactIdentifier()).thenReturn(factIdentifier2);
    abstractScesimGridModelSpy.updateFactMapping(simulationDescriptorMock, factMappingReference, INDEX, MULTIPART_VALUE, ScenarioHeaderMetaData.MetadataType.INSTANCE);
    verify(informationHeaderMetaDataMock, never()).setTitle(eq(MULTIPART_VALUE));
    verify(factMappingToCheck, never()).setFactAlias(eq(MULTIPART_VALUE));
}