/**
 * Copyright 1999-2015 dangdang.com.
 * <p>
 * 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.
 * </p>
 */

package com.dangdang.ddframe.job.internal.statistics;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.verify;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.quartz.JobExecutionException;
import org.unitils.util.ReflectionUtils;

import com.dangdang.ddframe.job.api.JobConfiguration;
import com.dangdang.ddframe.job.fixture.TestJob;
import com.dangdang.ddframe.job.internal.server.ServerService;

public final class ProcessCountJobTest {
    
    @Mock
    private ServerService serverService;
    
    private final ProcessCountJob processCountJob = new ProcessCountJob(null, new JobConfiguration("testJob", TestJob.class, 3, "0/1 * * * * ?"));
    
    @Before
    public void setUp() throws NoSuchFieldException {
        MockitoAnnotations.initMocks(this);
        ReflectionUtils.setFieldValue(processCountJob, "serverService", serverService);
    }
    
    @Test
    public void assertRun() throws JobExecutionException {
        ProcessCountStatistics.incrementProcessSuccessCount("testJob");
        ProcessCountStatistics.incrementProcessSuccessCount("testJob");
        ProcessCountStatistics.incrementProcessFailureCount("testJob");
        ProcessCountStatistics.incrementProcessFailureCount("testJob");
        ProcessCountStatistics.incrementProcessSuccessCount("otherTestJob");
        ProcessCountStatistics.incrementProcessFailureCount("otherTestJob");
        processCountJob.run();
        verify(serverService).persistProcessSuccessCount(2);
        verify(serverService).persistProcessFailureCount(2);
        assertThat(ProcessCountStatistics.getProcessSuccessCount("testJob"), is(0));
        assertThat(ProcessCountStatistics.getProcessFailureCount("testJob"), is(0));
        assertThat(ProcessCountStatistics.getProcessSuccessCount("otherTestJob"), is(1));
        assertThat(ProcessCountStatistics.getProcessFailureCount("otherTestJob"), is(1));
    }
}

@@ -1360,25 +1360,51 @@
 uration(
-%22testJob%22
+ProcessCountJobTest.class.getName()
 , TestJo
@@ -1773,33 +1773,59 @@
 uccessCount(
-%22testJob%22
+ProcessCountJobTest.class.getName()
 );%0A        P
@@ -1871,33 +1871,59 @@
 uccessCount(
-%22testJob%22
+ProcessCountJobTest.class.getName()
 );%0A        P
@@ -1969,33 +1969,59 @@
 ailureCount(
-%22testJob%22
+ProcessCountJobTest.class.getName()
 );%0A        P
@@ -2071,25 +2071,51 @@
 reCount(
-%22testJob%22
+ProcessCountJobTest.class.getName()
 );%0A     
@@ -2161,33 +2161,72 @@
 essSuccessCount(
-%22
+ProcessCountJobTest.class.getName() + %22_
 otherTestJob%22);%0A
@@ -2277,33 +2277,72 @@
 essFailureCount(
-%22
+ProcessCountJobTest.class.getName() + %22_
 otherTestJob%22);%0A
@@ -2555,33 +2555,59 @@
 uccessCount(
-%22testJob%22
+ProcessCountJobTest.class.getName()
 ), is(0));%0A 
@@ -2674,17 +2674,43 @@
 unt(
-%22testJob%22
+ProcessCountJobTest.class.getName()
 ), i
@@ -2777,25 +2777,64 @@
 uccessCount(
-%22
+ProcessCountJobTest.class.getName() + %22_
 otherTestJob
@@ -2910,17 +2910,56 @@
 reCount(
-%22
+ProcessCountJobTest.class.getName() + %22_
 otherTes

fix test case