Github user rafaelweingartner commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1057#discussion_r44524995 --- Diff: utils/src/main/java/com/cloud/utils/net/NetUtils.java --- @@ -775,11 +776,19 @@ public static String getSubNet(final String ip, final String netmask) { } public static String getCidrSubNet(final String ip, final long cidrSize) { - final long numericNetmask = 0xffffffff >> MAX_CIDR - cidrSize << MAX_CIDR - cidrSize; + final long numericNetmask = netMaskFromCidr(cidrSize); final String netmask = NetUtils.long2Ip(numericNetmask); return getSubNet(ip, netmask); } + /** + * @param cidrSize + * @return + */ + static long netMaskFromCidr(final long cidrSize) { + return ((long)0xffffffff) >> MAX_CIDR - cidrSize << MAX_CIDR - cidrSize; + } + --- End diff -- I think that it is fine letting the method with default modifier. The point of a test case is that we can/should write tests for a single method. Therefore, if we want to test the method âgetCidrSizeFromStringâ, we should write a test case for that specific method, and not for another one that uses it. After we make sure that a method works fine, when we test another method (letâs say âcidrToLongâ) that uses the first one already tested, we can use EasyMock/Mockito or another test suite to mock the method that we know works, this way we facilitate the writing of test cases.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---