/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.camunda.bpm.engine.test.api.cfg;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.ProcessEngineConfiguration;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration;
import org.camunda.bpm.engine.impl.history.HistoryLevel;
import org.junit.After;
import org.junit.Test;

public class HistoryLevelTest {

  protected ProcessEngine processEngine;

  @Test
  public void shouldInitHistoryLevelByObject() throws Exception {
    ProcessEngineConfigurationImpl config = new StandaloneInMemProcessEngineConfiguration();
    config.setHistoryLevel(HistoryLevel.HISTORY_LEVEL_FULL);

    ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config);

    assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4));
    assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL));
    assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName()));
  }

  @Test
  public void shouldInitHistoryLevelByString() throws Exception {
    ProcessEngineConfigurationImpl config = new StandaloneInMemProcessEngineConfiguration();
    config.setHistory(HistoryLevel.HISTORY_LEVEL_FULL.getName());

    ProcessEngineConfigurationImpl processEngineConfiguration = buildProcessEngine(config);

    assertThat(processEngineConfiguration.getHistoryLevels().size(), is(4));
    assertThat(processEngineConfiguration.getHistoryLevel(), is(HistoryLevel.HISTORY_LEVEL_FULL));
    assertThat(processEngineConfiguration.getHistory(), is(HistoryLevel.HISTORY_LEVEL_FULL.getName()));
  }

  protected ProcessEngineConfigurationImpl createConfig() {
    StandaloneInMemProcessEngineConfiguration configuration = new StandaloneInMemProcessEngineConfiguration();
    configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE);
    return configuration;
  }

  protected ProcessEngineConfigurationImpl buildProcessEngine(ProcessEngineConfigurationImpl config) {
    processEngine = config.buildProcessEngine();

    return (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
  }

  @After
  public void closeEngine() {
    processEngine.close();
  }

}
@@ -736,66 +736,8 @@
 ne;%0A
-import org.camunda.bpm.engine.ProcessEngineConfiguration;%0A
 impo
@@ -803,16 +803,16 @@
 onImpl;%0A
+
 import o
@@ -1187,53 +1187,20 @@
 g = 
-new StandaloneInMemProcessEngineConfiguration
+createConfig
 ();%0A
@@ -1761,53 +1761,20 @@
 g = 
-new StandaloneInMemProcessEngineConfiguration
+createConfig
 ();%0A
@@ -2414,78 +2414,111 @@
 .set
-DatabaseSchemaUpdate(P
+ProcessEngineName(%22p
 rocess
-E
+-e
 ngine
-Configuration.DB_SCHEMA_UPDATE_FALSE
+-HistoryTest%22);%0A    configuration.setJdbcUrl(%22jdbc:h2:mem:HistoryTest%22
 );%0A 

fix test case