<commit_before>/*
 * #%L
 * %%
 * Copyright (C) 2018 BMW Car IT GmbH
 * %%
 * 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.
 * #L%
 */
package io.joynr.systemintegrationtest.jee;

import static io.joynr.systemintegrationtest.jee.JoynrConfigurationProvider.CONTROLLER_DOMAIN;
import static io.joynr.systemintegrationtest.jee.JoynrConfigurationProvider.SIT_DOMAIN_PREFIX;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Stateless;
import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.joynr.arbitration.DiscoveryQos;
import io.joynr.jeeintegration.api.ProviderDomain;
import io.joynr.jeeintegration.api.ServiceLocator;
import io.joynr.jeeintegration.api.ServiceProvider;
import joynr.test.SitControllerSync;
import joynr.test.SystemIntegrationTestSync;

@Stateless
@ServiceProvider(serviceInterface = SitControllerSync.class)
@ProviderDomain(value = CONTROLLER_DOMAIN)
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class ControllerBean implements SitControllerSync {

    private static final Logger logger = LoggerFactory.getLogger(ControllerBean.class);
    private static String[] gbids = new String[]{ "joynrdefaultgbid", "othergbid" };

    private ServiceLocator serviceLocator;

    @Inject
    public ControllerBean(ServiceLocator serviceLocator) {
        this.serviceLocator = serviceLocator;
    }

    @Override
    public String ping() {
        logger.info("ping called");
        return "OK";
    }

    @Override
    public String waitForStatelessResult(Integer timeoutMs) {
        String errorMsg = "SIT RESULT error: waitForStatelessResult NOT IMPLEMENTED";
        logger.error(errorMsg);
        return errorMsg;
    }

    @Override
    public String triggerTests() {
        logger.info("triggerTests called");
        StringBuffer result = new StringBuffer();
        for (String appendValue : new String[]{ ".jee", ".cpp", ".java", ".node" }) {
            callProducer(SIT_DOMAIN_PREFIX + appendValue, result);
        }
        return Base64.getEncoder().encodeToString(result.toString().getBytes(StandardCharsets.UTF_8));
    }

    private void callProducer(String domain, StringBuffer result) {
        try {
            DiscoveryQos discoveryQos = new DiscoveryQos();
            discoveryQos.setDiscoveryTimeoutMs(120000); // 2 Minutes
            SystemIntegrationTestSync proxy = serviceLocator.builder(SystemIntegrationTestSync.class, domain)
                                                            .withDiscoveryQos(discoveryQos)
                                                            .withGbids(gbids)
                                                            .build();
            Integer additionResult = proxy.add(1, 1);
            if (additionResult != 2) {
                throw new IllegalArgumentException("1 + 1 should be 2, got: " + additionResult);
            }
            result.append("SIT RESULT success: JEE consumer -> ").append(domain);
        } catch (Exception e) {
            result.append("SIT RESULT error: JEE consumer -> ")
                  .append(domain)
                  .append("\nException: ")
                  .append(e.toString());
            Util.addStacktraceToResultString(e, result);
        }
        result.append("\n");<commit_msg>[SIT] Disabled triggering tests to c++, java, node providers in JEE consumer<commit_after>/*
 * #%L
 * %%
 * Copyright (C) 2018 BMW Car IT GmbH
 * %%
 * 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.
 * #L%
 */
package io.joynr.systemintegrationtest.jee;

import static io.joynr.systemintegrationtest.jee.JoynrConfigurationProvider.CONTROLLER_DOMAIN;
import static io.joynr.systemintegrationtest.jee.JoynrConfigurationProvider.SIT_DOMAIN_PREFIX;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Stateless;
import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.joynr.arbitration.DiscoveryQos;
import io.joynr.jeeintegration.api.ProviderDomain;
import io.joynr.jeeintegration.api.ServiceLocator;
import io.joynr.jeeintegration.api.ServiceProvider;
import joynr.test.SitControllerSync;
import joynr.test.SystemIntegrationTestSync;

@Stateless
@ServiceProvider(serviceInterface = SitControllerSync.class)
@ProviderDomain(value = CONTROLLER_DOMAIN)
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class ControllerBean implements SitControllerSync {

    private static final Logger logger = LoggerFactory.getLogger(ControllerBean.class);
    private static String[] gbids = new String[]{ "joynrdefaultgbid", "othergbid" };

    private ServiceLocator serviceLocator;

    @Inject
    public ControllerBean(ServiceLocator serviceLocator) {
        this.serviceLocator = serviceLocator;
    }

    @Override
    public String ping() {
        logger.info("ping called");
        return "OK";
    }

    @Override
    public String waitForStatelessResult(Integer timeoutMs) {
        String errorMsg = "SIT RESULT error: waitForStatelessResult NOT IMPLEMENTED";
        logger.error(errorMsg);
        return errorMsg;
    }

    @Override
    public String triggerTests() {
        logger.info("triggerTests called");
        StringBuffer result = new StringBuffer();
        //for (String appendValue : new String[]{ ".jee", ".cpp", ".java", ".node" }) {
        for (String appendValue : new String[]{ ".jee" }) {
            callProducer(SIT_DOMAIN_PREFIX + appendValue, result);
        }
        return Base64.getEncoder().encodeToString(result.toString().getBytes(StandardCharsets.UTF_8));
    }

    private void callProducer(String domain, StringBuffer result) {
        try {
            DiscoveryQos discoveryQos = new DiscoveryQos();
            discoveryQos.setDiscoveryTimeoutMs(120000); // 2 Minutes
            SystemIntegrationTestSync proxy = serviceLocator.builder(SystemIntegrationTestSync.class, domain)
                                                            .withDiscoveryQos(discoveryQos)
                                                            .withGbids(gbids)
                                                            .build();
            Integer additionResult = proxy.add(1, 1);
            if (additionResult != 2) {
                throw new IllegalArgumentException("1 + 1 should be 2, got: " + additionResult);
            }
            result.append("SIT RESULT success: JEE consumer -> ").append(domain);
        } catch (Exception e) {
            result.append("SIT RESULT error: JEE consumer -> ")
                  .append(domain)
                  .append("\nException: ")
                  .append(e.toString());
            Util.addStacktraceToResultString(e, result);
        }
        result.append("\n");
{'fraction_non_alphanumeric': 0.09273939851516295, 'fraction_numerical': 0.0070466842833773755, 'mean_word_length': 2.8620019436345965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4946192', 'n_tokens_mistral': 2163, 'n_tokens_neox': 2048, 'n_words': 542}