// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/CreateApplicationInstance.java
// public final class CreateApplicationInstance {
// 
// 	private final ServiceInstance serviceInstance;
// 
// 	public CreateApplicationInstance(ServiceInstance serviceInstance) {
// 		Assert.notNull(serviceInstance, "serviceInstance must not be null!");
// 		this.serviceInstance = serviceInstance;
// 	}
// 
// 	public ServiceInstance getServiceInstance() {
// 		return this.serviceInstance;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/DeleteApplicationInstance.java
// public final class DeleteApplicationInstance {
// 
// 	private final String id;
// 
// 	public DeleteApplicationInstance(String id) {
// 		Assert.notNull(id, "id must not be null!");
// 		this.id = id;
// 	}
// 
// 	public String getId() {
// 		return this.id;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/UpdateActuatorEndpoints.java
// public final class UpdateActuatorEndpoints {
// 
// 	private final String id;
// 	private final Links actuatorEndpoints;
// 
// 	public UpdateActuatorEndpoints(String id, Links actuatorEndpoints) {
// 		Assert.notNull(id, "id must not be null!");
// 		Assert.notNull(actuatorEndpoints, "actuatorEndpoints must not be null!");
// 		this.id = id;
// 		this.actuatorEndpoints = actuatorEndpoints;
// 	}
// 
// 	public String getId() {
// 		return this.id;
// 	}
// 
// 	public Links getActuatorEndpoints() {
// 		return this.actuatorEndpoints;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/UpdateApplicationInstanceHealth.java
// public final class UpdateApplicationInstanceHealth {
// 
// 	private final String id;
// 	private final Status healthStatus;
// 
// 	public UpdateApplicationInstanceHealth(String id, Status healthStatus) {
// 		Assert.notNull(id, "id must not be null!");
// 		Assert.notNull(healthStatus, "healthStatus must not be null!");
// 
// 		this.id = id;
// 		this.healthStatus = healthStatus;
// 	}
// 
// 	public String getId() {
// 		return this.id;
// 	}
// 
// 	public Status getHealthStatus() {
// 		return this.healthStatus;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceDeleted.java
// public class ApplicationInstanceDeleted extends ApplicationEvent {
// 
// 	public ApplicationInstanceDeleted(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// }


import java.net.URI;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import be.ordina.msdashboard.applicationinstance.commands.CreateApplicationInstance;
import be.ordina.msdashboard.applicationinstance.commands.DeleteApplicationInstance;
import be.ordina.msdashboard.applicationinstance.commands.UpdateActuatorEndpoints;
import be.ordina.msdashboard.applicationinstance.commands.UpdateApplicationInstanceHealth;
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceDeleted;
import org.springframework.boot.actuate.health.Status;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.verify;
import static org.mockito.BDDMockito.when;
/*
 * Copyright 2015-2019 the original author or authors.
 *
 * 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 be.ordina.msdashboard.applicationinstance;






/**
 * @author Tim Ysewyn
 */
@RunWith(MockitoJUnitRunner.class)
public class ApplicationInstanceServiceTests {

	@Mock
	private ServiceInstance serviceInstance;

	@Mock
	private ApplicationInstanceRepository repository;

	@InjectMocks
	private ApplicationInstanceService service;

	@Captor
	private ArgumentCaptor<ApplicationInstance> applicationInstanceArgumentCaptor;

	@Test
	public void shouldRetrieveApplicationInstanceFromRepository() {
		when(this.serviceInstance.getInstanceId()).thenReturn("a-1");
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/CreateApplicationInstance.java
// public final class CreateApplicationInstance {
// 
// 	private final ServiceInstance serviceInstance;
// 
// 	public CreateApplicationInstance(ServiceInstance serviceInstance) {
// 		Assert.notNull(serviceInstance, "serviceInstance must not be null!");
// 		this.serviceInstance = serviceInstance;
// 	}
// 
// 	public ServiceInstance getServiceInstance() {
// 		return this.serviceInstance;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/DeleteApplicationInstance.java
// public final class DeleteApplicationInstance {
// 
// 	private final String id;
// 
// 	public DeleteApplicationInstance(String id) {
// 		Assert.notNull(id, "id must not be null!");
// 		this.id = id;
// 	}
// 
// 	public String getId() {
// 		return this.id;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/UpdateActuatorEndpoints.java
// public final class UpdateActuatorEndpoints {
// 
// 	private final String id;
// 	private final Links actuatorEndpoints;
// 
// 	public UpdateActuatorEndpoints(String id, Links actuatorEndpoints) {
// 		Assert.notNull(id, "id must not be null!");
// 		Assert.notNull(actuatorEndpoints, "actuatorEndpoints must not be null!");
// 		this.id = id;
// 		this.actuatorEndpoints = actuatorEndpoints;
// 	}
// 
// 	public String getId() {
// 		return this.id;
// 	}
// 
// 	public Links getActuatorEndpoints() {
// 		return this.actuatorEndpoints;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/UpdateApplicationInstanceHealth.java
// public final class UpdateApplicationInstanceHealth {
// 
// 	private final String id;
// 	private final Status healthStatus;
// 
// 	public UpdateApplicationInstanceHealth(String id, Status healthStatus) {
// 		Assert.notNull(id, "id must not be null!");
// 		Assert.notNull(healthStatus, "healthStatus must not be null!");
// 
// 		this.id = id;
// 		this.healthStatus = healthStatus;
// 	}
// 
// 	public String getId() {
// 		return this.id;
// 	}
// 
// 	public Status getHealthStatus() {
// 		return this.healthStatus;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceDeleted.java
// public class ApplicationInstanceDeleted extends ApplicationEvent {
// 
// 	public ApplicationInstanceDeleted(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// }


// Path: microservices-dashboard-server-core/src/test/java/be/ordina/msdashboard/applicationinstance/ApplicationInstanceServiceTests.java
import java.net.URI;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import be.ordina.msdashboard.applicationinstance.commands.CreateApplicationInstance;
import be.ordina.msdashboard.applicationinstance.commands.DeleteApplicationInstance;
import be.ordina.msdashboard.applicationinstance.commands.UpdateActuatorEndpoints;
import be.ordina.msdashboard.applicationinstance.commands.UpdateApplicationInstanceHealth;
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceDeleted;
import org.springframework.boot.actuate.health.Status;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.verify;
import static org.mockito.BDDMockito.when;

/*
 * Copyright 2015-2019 the original author or authors.
 *
 * 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 be.ordina.msdashboard.applicationinstance;






/**
 * @author Tim Ysewyn
 */
@RunWith(MockitoJUnitRunner.class)
public class ApplicationInstanceServiceTests {

	@Mock
	private ServiceInstance serviceInstance;

	@Mock
	private ApplicationInstanceRepository repository;

	@InjectMocks
	private ApplicationInstanceService service;

	@Captor
	private ArgumentCaptor<ApplicationInstance> applicationInstanceArgumentCaptor;

	@Test
	public void shouldRetrieveApplicationInstanceFromRepository() {
		when(this.serviceInstance.getInstanceId()).thenReturn("a-1");
		when(this.repository.getById("a-1")).thenReturn(ApplicationInstanceMother.instance("a-1", "a"));