/*
 * Copyright (c) 2012 by The Author(s)
 *
 * 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 com.github.ferstl.maven.pomenforcers;

import java.io.File;

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.monitor.logging.DefaultLog;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.junit.Before;
import org.junit.Test;

import com.github.ferstl.maven.pomenforcers.PedanticModuleOrderEnforcer;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;


public class PedanticModuleOrderEnforcerTest {

  private EnforcerRuleHelper mockHelper;

  @Before
  public void setUp() throws Exception {
    this.mockHelper = mock(EnforcerRuleHelper.class);
    MavenProject mockProject = mock(MavenProject.class);
    when(mockProject.getFile()).thenReturn(new File("target/test-classes/test-pom.xml"));
    ConsoleLogger plexusLogger = new ConsoleLogger(Logger.LEVEL_DEBUG, "testLogger");
    when(this.mockHelper.getLog()).thenReturn(new DefaultLog(plexusLogger));
    when(this.mockHelper.evaluate("${project}")).thenReturn(mockProject);
  }

  @Test
  public void test() throws Exception {
    PedanticModuleOrderEnforcer rule = new PedanticModuleOrderEnforcer();
    rule.execute(this.mockHelper);
  }

}

@@ -1007,84 +1007,8 @@
 %0D%0A%0D%0A
-import com.github.ferstl.maven.pomenforcers.PedanticModuleOrderEnforcer;%0D%0A%0D%0A
 impo
@@ -1436,24 +1436,81 @@
 om.xml%22));%0D%0A
+    when(mockProject.getPackaging()).thenReturn(%22pom%22);%0D%0A
     ConsoleL

Configure pom packaging