IntentUtils { public static void verifySubjectInstance(final Subject subject, final Uuid intentId) throws IntentElementNotFoundException { if (!(subject instanceof EndPointGroup) && !(subject instanceof EndPointSelector) && !(subject instanceof EndPointGroupSelector)) { LOG.info("Subject is not specified: {}", intentId); throw new IntentElementNotFoundException(INVALID_SUBJECT_MESSAGE + intentId.getValue()); } } 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(expected = IntentElementNotFoundException.class) public void testVerifySubjectInstanceWithIntentElementNotFoundException() throws IntentInvalidException { subject = mock( org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.subjects.Subject.class); IntentUtils.verifySubjectInstance(subject, uuidMock); }
@Test public void testVerifySubjectInstanceWithEndPointGroup() { subject = mock( org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.subjects.Subject.class, Mockito.withSettings().extraInterfaces(EndPointGroup.class)); IntentUtils.verifySubjectInstance(subject, uuidMock); }
@Test public void testVerifySubjectInstanceWithEndPointSelector() { subject = mock( org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.subjects.Subject.class, Mockito.withSettings().extraInterfaces(EndPointSelector.class)); IntentUtils.verifySubjectInstance(subject, uuidMock); }
@Test public void testVerifySubjectInstanceWithEndPointGroupSelector() { subject = mock( org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.subjects.Subject.class, Mockito.withSettings() .extraInterfaces(EndPointGroupSelector.class)); IntentUtils.verifySubjectInstance(subject, uuidMock); }