/*
 * Copyright 2016, Jürgen Dufner
 *
 * 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 de.jdufner.microservice.primes;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.beans.factory.ObjectFactory;

/**
 * @author Jürgen Dufner
 * @since 0.0.1
 */
@RunWith(MockitoJUnitRunner.class)
public class PrimesControllerTest {

  @InjectMocks
  private PrimesController primesController;

  @Mock
  private ObjectFactory<PrimesComputer> primesComputerObjectFactory;

  @Test
  public void testPrimes() {
    // arrange
    Mockito.when(primesComputerObjectFactory.getObject()).thenReturn(new PrimesComputer());

    // act
    PrimesResult primesResult = primesController.primes(100);

    // assert
    Assertions.assertThat(primesResult.getDivisionCounter()).isEqualTo(235);
  }

}
@@ -916,16 +916,127 @@
 actory;%0A
+import org.springframework.test.util.ReflectionTestUtils;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 %0A/**%0A * 
@@ -1242,16 +1242,29 @@
 Factory%3C
+List%3CAbstract
 PrimesCo
@@ -1270,16 +1270,17 @@
 omputer%3E
+%3E
  primesC
@@ -1298,17 +1298,19 @@
 ctFactor
-y
+ies
 ;%0A%0A  @Te
@@ -1356,16 +1356,225 @@
 arrange%0A
+    List%3CAbstractPrimesComputer%3E primesComputers = new ArrayList%3C%3E();%0A    PrimesOnlyPrimesComputer primesOnlyPrimesComputer = new PrimesOnlyPrimesComputer();%0A    primesComputers.add(primesOnlyPrimesComputer);%0A
     Mock
@@ -1608,17 +1608,19 @@
 ctFactor
-y
+ies
 .getObje
@@ -1640,26 +1640,138 @@
 urn(
-new PrimesComputer
+primesComputers);%0A    ReflectionTestUtils.setField(primesController, %22strategy%22, primesOnlyPrimesComputer.getClass().getSimpleName
 ());
@@ -1902,44 +1902,20 @@
 sult
-.getDivisionCounter()).isEqualTo(235
+).isNotNull(
 );%0A 
@@ -1919,8 +1919,9 @@
 ;%0A  %7D%0A%0A%7D
+%0A

Fix Test