/**
 *    Retz
 *    Copyright (C) 2016 Nautilus Technologies, Inc.
 *
 *    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 io.github.retz.executor;

import org.junit.After;
import org.junit.Test;
import scala.actors.threadpool.Arrays;
import xerial.jnuma.Numa;

import java.util.List;

public class CPUManagerTest {

    @After
    public void after() {
        CPUManager.reset();
    }

    @Test
    public void numaTopologyDetection() {

        if (Numa.isAvailable()) {
            // Only one socket isn't NUMA?
            assert Numa.numNodes() > 0;
            assert Numa.numCPUs() > 1;

            CPUManager manager = CPUManager.get();
            assert manager.availableCPUCount() == Numa.numCPUs();
            assert manager.availableCPUCount() == Runtime.getRuntime().availableProcessors();

        }
    }

    @Test
    public void cpuManagerTest() {
        CPUManager manager = CPUManager.get();

        // Assuming test machine has more than two CPU cores
        List<Integer> cpus = manager.assign("foobar", 2);
        assert cpus.size() == 2;

        manager.free("foobar");
        assert manager.availableCPUCount() == Runtime.getRuntime().availableProcessors();
    }
    @Test
    public void crossNodeTest() {
        Integer[] nodes = {4, 4, 4, 4}; // 4x4 numa structure
        CPUManager.setTopology(Arrays.asList(nodes));

        assert CPUManager.get().availableCPUCount() == 4 * nodes.length;
        System.err.println(CPUManager.get().toString());

        List<Integer> cpus = CPUManager.get().assign("hey><", 7);
        System.err.println("Assigned: [" + CPUManager.listIntToString(cpus) + "]");
        assert cpus.size() == 7;

        CPUManager.get().free("hey><");
        assert CPUManager.get().availableCPUCount() == 4 * nodes.length;
    }
}

@@ -821,16 +821,105 @@
 .List;%0A%0A
+import static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0A
 public c
@@ -1065,16 +1065,62 @@
 ion() %7B%0A
+        CPUManager manager = CPUManager.get();
 %0A       
@@ -1199,33 +1199,37 @@
           assert
- 
+True(
 Numa.numNodes() 
@@ -1231,16 +1231,17 @@
 es() %3E 0
+)
 ;%0A      
@@ -1252,17 +1252,21 @@
   assert
- 
+True(
 Numa.num
@@ -1275,16 +1275,17 @@
 Us() %3E 1
+)
 ;%0A%0A     
@@ -1295,65 +1295,36 @@
     
-CPUManager manager = CPUManager.get();%0A            assert
+assertEquals(Numa.numCPUs(),
  man
@@ -1351,25 +1351,8 @@
 nt()
- == Numa.numCPUs(
 );%0A 
@@ -1360,52 +1360,33 @@
     
+  %7D%0A
       
+  
 assert
- manager.availableCPUCount() == 
+Equals(
 Runt
@@ -1427,20 +1427,39 @@
 rs()
-;%0A%0A        %7D
+, manager.availableCPUCount());
 %0A   
@@ -1680,33 +1680,39 @@
 ;%0A        assert
- 
+Equals(
 cpus.size() == 2
@@ -1710,13 +1710,12 @@
 ze()
- ==
+,
  2
+)
 ;%0A%0A 
@@ -1741,24 +1741,25 @@
 (%22foobar%22);%0A
+%0A
         asse
@@ -1764,40 +1764,15 @@
 sert
- manager.availableCPUCount() == 
+Equals(
 Runt
@@ -1809,24 +1809,54 @@
 essors()
+, manager.availableCPUCount())
 ;%0A    %7D%0A
     @Tes
@@ -1843,24 +1843,25 @@
 t());%0A    %7D%0A
+%0A
     @Test%0A  
@@ -2015,32 +2015,56 @@
 %0A%0A        assert
+Equals(4 * nodes.length,
  CPUManager.get(
@@ -2084,36 +2084,17 @@
 UCount()
- == 4 * nodes.length
+)
 ;%0A      
@@ -2309,16 +2309,25 @@
   assert
+Equals(7,
  cpus.si
@@ -2334,13 +2334,9 @@
 ze()
- == 7
+)
 ;%0A%0A 
@@ -2388,16 +2388,40 @@
   assert
+Equals(4 * nodes.length,
  CPUMana
@@ -2453,28 +2453,9 @@
 nt()
- == 4 * nodes.length
+)
 ;%0A  

Change from assert to org.junit.Assert.*