<commit_before>/*
 * Copyright 2016 MICRORISC s.r.o..
 *
 * 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.microrisc.simply.iqrf.dpa.v22x.services.node.load_code;

import com.microrisc.simply.BaseNode;
import com.microrisc.simply.DeviceObject;
import com.microrisc.simply.iqrf.dpa.v22x.devices.OS;
import com.microrisc.simply.iqrf.dpa.v22x.types.LoadingCodeProperties;
import com.microrisc.simply.iqrf.types.VoidType;
import com.microrisc.simply.services.ServiceParameters;
import com.microrisc.simply.services.ServiceResult;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Fs
 */
public class SimpleLoadCodeServiceTest {
    
    public SimpleLoadCodeServiceTest() {
    }
    
    @BeforeClass
    public static void setUpClass() {
    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    /**
     * Unicast ok.
     */
    @Test
    public void unicastOk() {
        TestingOs os = new TestingOs("1", "1");
        os.setBatchReturnValue(new VoidType());
        
        Map<Class, DeviceObject> deviceObjects = new HashMap<>();
        deviceObjects.put(OS.class, (DeviceObject)os);
        LoadCodeService loadCodeService 
                = new SimpleLoadCodeService( new BaseNode("1", "1", deviceObjects));
        
        String sourceFile = "load_code_service" + File.separator + "CustomDpaHandler-LED-Green-On-7xD-V300-161122.hex";
        LoadCodeServiceParameters params
                = new LoadCodeServiceParameters(sourceFile, 
                        0x0000,
                        LoadingCodeProperties.LoadingAction.ComputeAndMatchChecksumWithoutCodeLoading,
                        LoadingCodeProperties.LoadingContent.Hex
                );
        
        ServiceResult<LoadCodeResult, LoadCodeProcessingInfo> serviceResult 
                = loadCodeService.loadCode(params);
        
        assertEquals(serviceResult.getStatus(), ServiceResult.Status.SUCCESSFULLY_COMPLETED);
        assertNull(serviceResult.getProcessingInfo().getError());
        
        LoadCodeResult loadResult = serviceResult.getResult();
        Map<String, Boolean> loadResultsMap = loadResult.getAllNodeResultsMap();
        assertNotNull(loadResultsMap);
        assertEquals(loadResultsMap.size(), 1);
        
        Boolean nodeResult = loadResult.getNodeResult("1");
        assertNotNull(nodeResult);
        assertEquals(true, nodeResult);
    }
    
}<commit_msg>Simply IQRF Dpa v22x: - commented(inactivated) test for Load Code Service<commit_after>/*
 * Copyright 2016 MICRORISC s.r.o..
 *
 * 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.microrisc.simply.iqrf.dpa.v22x.services.node.load_code;

import com.microrisc.simply.BaseNode;
import com.microrisc.simply.DeviceObject;
import com.microrisc.simply.iqrf.dpa.v22x.devices.OS;
import com.microrisc.simply.iqrf.dpa.v22x.types.LoadingCodeProperties;
import com.microrisc.simply.iqrf.types.VoidType;
import com.microrisc.simply.services.ServiceResult;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author Fs
 */
public class SimpleLoadCodeServiceTest {
    
    public SimpleLoadCodeServiceTest() {
    }
    
    @BeforeClass
    public static void setUpClass() {
    }
    
    @AfterClass
    public static void tearDownClass() {
    }
    
    @Before
    public void setUp() {
    }
    
    @After
    public void tearDown() {
    }

    /**
     * Unicast ok.
     */
    /*
    @Test
    public void unicastOk() {
        TestingOs os = new TestingOs("1", "1");
        os.setBatchReturnValue(new VoidType());
        
        Map<Class, DeviceObject> deviceObjects = new HashMap<>();
        deviceObjects.put(OS.class, (DeviceObject)os);
        LoadCodeService loadCodeService 
                = new SimpleLoadCodeService( new BaseNode("1", "1", deviceObjects));
        
        String sourceFile = "load_code_service" + File.separator + "CustomDpaHandler-LED-Green-On-7xD-V300-161122.hex";
        LoadCodeServiceParameters params
                = new LoadCodeServiceParameters(sourceFile, 
                        0x0000,
                        LoadingCodeProperties.LoadingAction.ComputeAndMatchChecksumWithoutCodeLoading,
                        LoadingCodeProperties.LoadingContent.Hex
                );
        
        ServiceResult<LoadCodeResult, LoadCodeProcessingInfo> serviceResult 
                = loadCodeService.loadCode(params);
        
        assertEquals(serviceResult.getStatus(), ServiceResult.Status.SUCCESSFULLY_COMPLETED);
        assertNull(serviceResult.getProcessingInfo().getError());
        
        LoadCodeResult loadResult = serviceResult.getResult();
        Map<String, Boolean> loadResultsMap = loadResult.getAllNodeResultsMap();
        assertNotNull(loadResultsMap);
        assertEquals(loadResultsMap.size(), 1);
        
        Boolean nodeResult = loadResult.getNodeResult("1");
        assertNotNull(nodeResult);
        assertEquals(true, nodeResult);
    }
    */
}
{'fraction_non_alphanumeric': 0.09506878961199568, 'fraction_numerical': 0.011130004637501932, 'mean_word_length': 2.885885885885886, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6726933', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1800, 'n_words': 419}