// Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
// 
// 	ACTIVE_DIRECTORY("ad") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// 			return ActiveDirectoryConverter.TO_RESOURCE;
// 		}
// 	},
// 	LDAP("ldap") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, LdapResource> getToResourceMapper() {
// 			return LdapConverter.TO_RESOURCE;
// 		}
// 	},
// 	SAML("saml") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, SamlResource> getToResourceMapper() {
// 			return SamlConverter.TO_RESOURCE;
// 		}
// 	};
// 
// 	private String name;
// 
// 	AuthIntegrationType(String name) {
// 		this.name = name;
// 	}
// 
// 	public abstract Optional<Integration> get(Integration entity);
// 
// 	public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public static Optional<AuthIntegrationType> fromId(String id) {
// 		return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return this.name;
// 	}
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
// 
// 	void validate(Integration integration);
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
// 
// 	void validate(T authRequest);
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// 	ParameterUtils.setLdapParameters(request, integration);
// 	integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };


import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST;
/*
 * Copyright 2019 EPAM Systems
 *
 * 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 com.epam.reportportal.auth.integration.handler.impl.strategy;



/**
 * @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
 */
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {

	@Autowired
	public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository,
			@Qualifier("ldapUpdateAuthRequestValidator") AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator, IntegrationDuplicateValidator integrationDuplicateValidator) {
		super(integrationRepository, updateAuthRequestValidator, integrationDuplicateValidator);
	}

	@Override
	protected void fill(Integration integration, UpdateAuthRQ updateRequest) {
// Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
// 
// 	ACTIVE_DIRECTORY("ad") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// 			return ActiveDirectoryConverter.TO_RESOURCE;
// 		}
// 	},
// 	LDAP("ldap") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, LdapResource> getToResourceMapper() {
// 			return LdapConverter.TO_RESOURCE;
// 		}
// 	},
// 	SAML("saml") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, SamlResource> getToResourceMapper() {
// 			return SamlConverter.TO_RESOURCE;
// 		}
// 	};
// 
// 	private String name;
// 
// 	AuthIntegrationType(String name) {
// 		this.name = name;
// 	}
// 
// 	public abstract Optional<Integration> get(Integration entity);
// 
// 	public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public static Optional<AuthIntegrationType> fromId(String id) {
// 		return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return this.name;
// 	}
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/duplicate/IntegrationDuplicateValidator.java
// public interface IntegrationDuplicateValidator {
// 
// 	void validate(Integration integration);
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/validator/request/AuthRequestValidator.java
// public interface AuthRequestValidator<T> {
// 
// 	void validate(T authRequest);
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/converter/LdapConverter.java
// public static final BiConsumer<UpdateAuthRQ, Integration> UPDATE_FROM_REQUEST = (request, integration) -> {
// 	ParameterUtils.setLdapParameters(request, integration);
// 	integration.setEnabled(ofNullable(request.getEnabled()).orElse(false));
// };


// Path: src/main/java/com/epam/reportportal/auth/integration/handler/impl/strategy/ActiveDirectoryIntegrationStrategy.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.validator.duplicate.IntegrationDuplicateValidator;
import com.epam.reportportal.auth.integration.validator.request.AuthRequestValidator;
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import static com.epam.reportportal.auth.integration.converter.LdapConverter.UPDATE_FROM_REQUEST;

/*
 * Copyright 2019 EPAM Systems
 *
 * 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 com.epam.reportportal.auth.integration.handler.impl.strategy;



/**
 * @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a>
 */
@Service
public class ActiveDirectoryIntegrationStrategy extends AuthIntegrationStrategy {

	@Autowired
	public ActiveDirectoryIntegrationStrategy(IntegrationRepository integrationRepository,
			@Qualifier("ldapUpdateAuthRequestValidator") AuthRequestValidator<UpdateAuthRQ> updateAuthRequestValidator, IntegrationDuplicateValidator integrationDuplicateValidator) {
		super(integrationRepository, updateAuthRequestValidator, integrationDuplicateValidator);
	}

	@Override
	protected void fill(Integration integration, UpdateAuthRQ updateRequest) {
		integration.setName(AuthIntegrationType.ACTIVE_DIRECTORY.getName());