### Question:
OutputHelper { public static int[] manualMapping(int src[], int mapping[], int xResolution, int yResolution) { int bufferTwo[] = new int[mapping.length]; int length = src.length; int ofs=0; for (int i: mapping) { if (i+1>length) { LOG.log(Level.SEVERE, "Your manual mapping is wrong,the first index is 0! Invalid entry index: {0}", i); } else { bufferTwo[ofs++] = src[i]; } } return bufferTwo; } private  OutputHelper(); static int[] flipSecondScanline(int buffer[], int xResolution, int yResolution); static int[] manualMapping(int src[], int mapping[], int xResolution, int yResolution); static byte[] convertBufferTo15bit(int[] data, ColorFormat colorFormat); static byte[] convertBufferTo15bit(int[] data, ColorFormat colorFormat, RGBAdjust correction); static byte[] convertBufferTo24bit(int[] data, ColorFormat colorFormat); static String getSerialPortName(String configuredName);  }### Answer:
@Test public void testOutputMapping() { int[] ret; int[] mapping = new int[] { 3,1,4,5,2,0 }; int[] buffer = new int[] { 1,2,3, 4,5,6 }; ret = OutputHelper.manualMapping(buffer, mapping, 3, 2); RotateBufferTest.dumpBuffer(ret); assertEquals(4, ret[0]); assertEquals(2, ret[1]); assertEquals(5, ret[2]); assertEquals(6, ret[3]); assertEquals(3, ret[4]); assertEquals(1, ret[5]); }
@Test public void testOutputMappingWrong() { int[] mapping = new int[160]; int[] buffer = new int[160]; for (int i=0; i<160; i++) { mapping[i] = i+1; } OutputHelper.manualMapping(buffer, mapping, 8, 20); }