IntentUtils { public static boolean verifyIntentSubjects(final Intent intent) { boolean result = true; final List<Subjects> subjects = intent.getSubjects(); if (subjects == null || subjects.size() != NUM_OF_SUPPORTED_EPG) { LOG.warn("Intent's subjects is either null or not equal to {} subjects {}", NUM_OF_SUPPORTED_EPG, intent); result = false; } return result; } private  IntentUtils(); static boolean validateMAC(final String mac); static boolean validateIP(String ip); static boolean verifyIntent(final Intent intent); static boolean verifyIntentActions(final Intent intent); static boolean verifyIntentSubjects(final Intent intent); static List<String> extractEndPointGroup(final Intent intent); static List<EndPointGroup> extractEndPointGroups(final Intent intent); static EndPointGroup extractSrcEndPointGroup(final Intent intent); static EndPointGroup extractDstEndPointGroup(final Intent intent); static void verifySubjectInstance(final Subject subject, final Uuid intentId); static Action getAction(final Intent intent); static final Integer SRC_END_POINT_GROUP_INDEX; static final Integer DST_END_POINT_GROUP_INDEX; static final InstanceIdentifier<Intents> INTENTS_IID; static final InstanceIdentifier<IntentsLimiter> INTENTS_LIMITER_IDD; static final InstanceIdentifier<IntentIspPrefixes> INTENT_ISP_PREFIX_IID; }
@Test public void testIntentSubjectsSizeSupported() { boolean result; Mockito.when(intentMock.getSubjects()).thenReturn(null); result = IntentUtils.verifyIntentSubjects(intentMock); Assert.assertFalse(result); Mockito.when(intentMock.getSubjects()).thenReturn(subjectsMock); Mockito.when(subjectsMock.size()).thenReturn(0); result = IntentUtils.verifyIntentSubjects(intentMock); Assert.assertFalse(result); Mockito.when(subjectsMock.size()).thenReturn(1); result = IntentUtils.verifyIntentSubjects(intentMock); Assert.assertFalse(result); Mockito.when(subjectsMock.size()).thenReturn(2); result = IntentUtils.verifyIntentSubjects(intentMock); Assert.assertTrue(result); Mockito.when(subjectsMock.size()).thenReturn(3); result = IntentUtils.verifyIntentSubjects(intentMock); Assert.assertFalse(result); Mockito.when(subjectsMock.size()).thenReturn(4); result = IntentUtils.verifyIntentSubjects(intentMock); Assert.assertFalse(result); }