/*
 * Autosleep
 * Copyright (C) 2016 Orange
 * Authors: Benjamin Einaudi   benjamin.einaudi@orange.com
 *          Arnaud Ruffin      arnaud.ruffin@orange.com
 *
 * 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.cloudfoundry.autosleep.dao.model;

import lombok.extern.slf4j.Slf4j;
import org.cloudfoundry.autosleep.util.BeanGenerator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

@RunWith(MockitoJUnitRunner.class)
@Slf4j
public class ApplicationInfoTest {

    @Test
    public void testIsWatched() throws Exception {
        ApplicationInfo info = BeanGenerator.createAppInfo();
        assertFalse(info.getEnrollmentState().isWatched());
        String serviceId = "testIsWatched";
        info.getEnrollmentState().addEnrollmentState(serviceId);
        assertTrue(info.getEnrollmentState().isWatched());

        info.getEnrollmentState().updateEnrollment(serviceId, true);
        assertFalse(info.getEnrollmentState().isWatched());

        info.getEnrollmentState().addEnrollmentState(serviceId);
        info.getEnrollmentState().updateEnrollment(serviceId, false);
        assertFalse(info.getEnrollmentState().isWatched());
    }

}
@@ -1147,27 +1147,41 @@
 ic void test
-IsW
+_default_is_not_w
 atched() thr
@@ -1196,16 +1196,59 @@
 ption %7B%0A
+        //Given a default application info%0A
         
@@ -1305,65 +1305,338 @@
 ();%0A
-        assertFalse(info.getEnrollmentState().isWatched()
+%0A        //When asked if watched%0A        //Then it returns false%0A        assertFalse(info.getEnrollmentState().isWatched());%0A    %7D%0A%0A    @Test%0A    public void test_adding_a_service_move_enrollment_to_watched() throws Exception %7B%0A        //Given a default application info%0A        ApplicationInfo info = BeanGenerator.createAppInfo(
 );%0A 
@@ -1678,16 +1678,48 @@
 tched%22;%0A
+        //When adding a service%0A
         
@@ -1767,32 +1767,70 @@
 ate(serviceId);%0A
+        //Then application is watched%0A
         assertTr
@@ -1864,32 +1864,415 @@
 ).isWatched());%0A
+    %7D%0A%0A    @Test%0A    public void test_blacklist_on_single_existing_set_not_watched() throws Exception %7B%0A        //Given a default application info that is watched by a service%0A        ApplicationInfo info = BeanGenerator.createAppInfo();%0A        String serviceId = %22testIsWatched%22;%0A        info.getEnrollmentState().addEnrollmentState(serviceId);%0A%0A        //When removing the service
 %0A        info.ge
@@ -2324,16 +2324,67 @@
 , true);
+%0A%0A        //Then applications is no longuer watched
 %0A       
@@ -2441,202 +2441,8 @@
 );%0A%0A
-        info.getEnrollmentState().addEnrollmentState(serviceId);%0A        info.getEnrollmentState().updateEnrollment(serviceId, false);%0A        assertFalse(info.getEnrollmentState().isWatched());
 %0A   

Refactor of ApplicationInfoTest