/*
 * Copyright 2015 Dmitry Ustalov
 *
 * 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 mtsar;

import com.google.common.collect.Maps;
import io.dropwizard.testing.junit.ResourceTestRule;
import mtsar.api.Process;
import mtsar.resources.ProcessResource;
import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.mockito.internal.util.collections.Sets;

import javax.ws.rs.core.GenericType;
import java.util.Collection;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class ProcessResourceTest {
    private static final mtsar.api.Process process = mock(Process.class);

    @ClassRule
    public static final ResourceTestRule RULE = ResourceTestRule.builder()
            .setTestContainerFactory(new GrizzlyTestContainerFactory())
            .addResource(new ProcessResource(Maps.asMap(Sets.newSet("1"), (id) -> process), null, null, null))
            .build();

    @Before
    public void setup() {
        when(process.getId()).thenReturn("1");
    }

    @Test
    public void testGetProcesses() {
        final Collection<Map> processes = RULE.getJerseyTest().target("/processes").request().get(new GenericType<Collection<Map>>() {
        });
        assertThat(processes).hasSize(1);
        final Map representation = processes.iterator().next();
        assertThat(representation.get("id")).isEqualTo(process.getId());
    }
}

@@ -726,16 +726,171 @@
 rocess;%0A
+import mtsar.api.ProcessDefinition;%0Aimport mtsar.processors.AnswerAggregator;%0Aimport mtsar.processors.TaskAllocator;%0Aimport mtsar.processors.WorkerRanker;%0A
 import m
@@ -921,16 +921,16 @@
 source;%0A
-
 import o
@@ -1411,54 +1411,434 @@
 nal 
-mtsar.api.Process process = mock(Process.class
+ProcessDefinition definition = mock(ProcessDefinition.class);%0A    private static final WorkerRanker workerRanker = mock(WorkerRanker.class);%0A    private static final TaskAllocator taskAllocator = mock(TaskAllocator.class);%0A    private static final AnswerAggregator answerAggregator = mock(AnswerAggregator.class);%0A    private static final Process process = new Process(definition, workerRanker, taskAllocator, answerAggregator
 );%0A%0A
@@ -2461,16 +2461,16 @@
 ize(1);%0A
-
         
@@ -2525,16 +2525,64 @@
 next();%0A
+        assertThat(representation).isNotNull();%0A
         

Create the Process instance manually in ProcessResourceTest [ci skip]