@Test public void testErrorLookupExists() { when(kernel32.GetLastError()).thenReturn(WinError.ERROR_INSUFFICIENT_BUFFER); assertEquals("ERROR_INSUFFICIENT_BUFFER(" + WinError.ERROR_INSUFFICIENT_BUFFER + ")", errorLookup.getLastError()); }
public String getLastError() { int lastError = kernel32.GetLastError(); return Arrays.stream(WinError.class.getDeclaredFields()).filter(field -> { try { return Modifier.isStatic(field.getModifiers()) && field.getType() == int.class && field.getName().startsWith("ERROR") && (int) field.get(null) == lastError; } catch (IllegalAccessException e) { return false; } }).map(field -> field.getName() + "(" + lastError + ")") .findFirst() .orElse(Integer.toString(lastError)); }
ErrorLookup { public String getLastError() { int lastError = kernel32.GetLastError(); return Arrays.stream(WinError.class.getDeclaredFields()).filter(field -> { try { return Modifier.isStatic(field.getModifiers()) && field.getType() == int.class && field.getName().startsWith("ERROR") && (int) field.get(null) == lastError; } catch (IllegalAccessException e) { return false; } }).map(field -> field.getName() + "(" + lastError + ")") .findFirst() .orElse(Integer.toString(lastError)); } }
ErrorLookup { public String getLastError() { int lastError = kernel32.GetLastError(); return Arrays.stream(WinError.class.getDeclaredFields()).filter(field -> { try { return Modifier.isStatic(field.getModifiers()) && field.getType() == int.class && field.getName().startsWith("ERROR") && (int) field.get(null) == lastError; } catch (IllegalAccessException e) { return false; } }).map(field -> field.getName() + "(" + lastError + ")") .findFirst() .orElse(Integer.toString(lastError)); } ErrorLookup(Kernel32 kernel32); }
ErrorLookup { public String getLastError() { int lastError = kernel32.GetLastError(); return Arrays.stream(WinError.class.getDeclaredFields()).filter(field -> { try { return Modifier.isStatic(field.getModifiers()) && field.getType() == int.class && field.getName().startsWith("ERROR") && (int) field.get(null) == lastError; } catch (IllegalAccessException e) { return false; } }).map(field -> field.getName() + "(" + lastError + ")") .findFirst() .orElse(Integer.toString(lastError)); } ErrorLookup(Kernel32 kernel32); String getLastError(); }
ErrorLookup { public String getLastError() { int lastError = kernel32.GetLastError(); return Arrays.stream(WinError.class.getDeclaredFields()).filter(field -> { try { return Modifier.isStatic(field.getModifiers()) && field.getType() == int.class && field.getName().startsWith("ERROR") && (int) field.get(null) == lastError; } catch (IllegalAccessException e) { return false; } }).map(field -> field.getName() + "(" + lastError + ")") .findFirst() .orElse(Integer.toString(lastError)); } ErrorLookup(Kernel32 kernel32); String getLastError();  }