src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
IngestMetricsBuilder { public static IngestMetrics createInterpretedToEsIndexMetrics() { return IngestMetrics.create().addMetric(GbifJsonTransform.class, AVRO_TO_JSON_COUNT); } static IngestMetrics createVerbatimToInterpretedMetrics(); static IngestMetrics createInterpretedToEsIndexMetrics(); static IngestMetrics crea... | @Test public void createInterpretedToEsIndexMetricsTest() { IngestMetrics metrics = IngestMetricsBuilder.createInterpretedToEsIndexMetrics(); metrics.incMetric(AVRO_TO_JSON_COUNT); MetricResults result = metrics.getMetricsResult(); Map<String, Long> map = new HashMap<>(); result .allMetrics() .getCounters() .forEach(mr... |
IngestMetricsBuilder { public static IngestMetrics createInterpretedToHdfsViewMetrics() { return IngestMetrics.create() .addMetric(OccurrenceHdfsRecordConverterTransform.class, AVRO_TO_HDFS_COUNT); } static IngestMetrics createVerbatimToInterpretedMetrics(); static IngestMetrics createInterpretedToEsIndexMetrics(); st... | @Test public void createInterpretedToHdfsViewMetricsTest() { IngestMetrics metrics = IngestMetricsBuilder.createInterpretedToHdfsViewMetrics(); metrics.incMetric(AVRO_TO_HDFS_COUNT); MetricResults result = metrics.getMetricsResult(); Map<String, Long> map = new HashMap<>(); result .allMetrics() .getCounters() .forEach(... |
ProcessRunnerBuilder { ProcessBuilder get() { if (StepRunner.DISTRIBUTED.name().equals(config.processRunner)) { return buildSpark(); } throw new IllegalArgumentException("Wrong runner type - " + config.processRunner); } String[] buildOptions(); } | @Test public void testSparkRunnerCommand() { String expected = "spark2-submit --conf spark.default.parallelism=1 --conf spark.executor.memoryOverhead=1 " + "--conf spark.dynamicAllocation.enabled=false " + "--class org.gbif.Test --master yarn --deploy-mode cluster --executor-memory 1G --executor-cores 1 --num-executors... |
Columns { public static String column(Term term) { if (term instanceof GbifInternalTerm || TermUtils.isOccurrenceJavaProperty(term) || GbifTerm.mediaType == term) { return column(term, ""); } else if (TermUtils.isInterpretedSourceTerm(term)) { throw new IllegalArgumentException( "The term " + term + " is interpreted an... | @Test public void testGetColumn() { assertEquals("scientificName", Columns.column(DwcTerm.scientificName)); assertEquals("countryCode", Columns.column(DwcTerm.countryCode)); assertEquals("v_catalogNumber", Columns.column(DwcTerm.catalogNumber)); assertEquals("class", Columns.column(DwcTerm.class_)); assertEquals("order... |
Columns { public static String verbatimColumn(Term term) { if (term instanceof GbifInternalTerm) { throw new IllegalArgumentException( "Internal terms (like the tried [" + term.simpleName() + "]) do not exist as verbatim columns"); } return column(term, VERBATIM_TERM_PREFIX); } static String column(Term term); static ... | @Test(expected = IllegalArgumentException.class) public void testGetVerbatimColumnIllegal() { Columns.verbatimColumn(GbifInternalTerm.crawlId); }
@Test public void testGetVerbatimColumn() { assertEquals("v_basisOfRecord", Columns.verbatimColumn(DwcTerm.basisOfRecord)); } |
XmlFragmentParser { public static List<RawOccurrenceRecord> parseRecord(RawXmlOccurrence xmlRecord) { return parseRecord(xmlRecord.getXml(), xmlRecord.getSchemaType()); } private XmlFragmentParser(); static List<RawOccurrenceRecord> parseRecord(RawXmlOccurrence xmlRecord); static List<RawOccurrenceRecord> parseRecord(... | @Test public void testUtf8a() throws IOException { String xml = Resources.toString( Resources.getResource("id_extraction/abcd1_umlaut.xml"), StandardCharsets.UTF_8); RawXmlOccurrence rawRecord = createFakeOcc(xml); List<RawOccurrenceRecord> results = XmlFragmentParser.parseRecord(rawRecord); assertEquals(1, results.siz... |
XmlFragmentParser { public static Set<IdentifierExtractionResult> extractIdentifiers( UUID datasetKey, byte[] xml, OccurrenceSchemaType schemaType, boolean useTriplet, boolean useOccurrenceId) { Set<IdentifierExtractionResult> results = Sets.newHashSet(); List<RawOccurrenceRecord> records = parseRecord(xml, schemaType)... | @Test public void testIdExtractionSimple() throws IOException { String xml = Resources.toString( Resources.getResource("id_extraction/abcd1_simple.xml"), StandardCharsets.UTF_8); UUID datasetKey = UUID.randomUUID(); Triplet target = new Triplet( datasetKey, "TLMF", "Tiroler Landesmuseum Ferdinandeum", "82D45C93-B297-49... |
HttpResponseParser { static Set<String> parseIndexesInAliasResponse(HttpEntity entity) { return JsonHandler.readValue(entity).keySet(); } } | @Test public void parseIndexesTest() { String path = "/responses/alias-indexes.json"; Set<String> indexes = HttpResponseParser.parseIndexesInAliasResponse(getEntityFromResponse(path)); assertEquals(2, indexes.size()); assertTrue(indexes.contains("idx1")); assertTrue(indexes.contains("idx2")); } |
ResponseSchemaDetector { public OccurrenceSchemaType detectSchema(String xml) { OccurrenceSchemaType result = null; for (OccurrenceSchemaType schema : schemaSearchOrder) { log.debug("Checking for schema [{}]", schema); boolean success = checkElements(xml, distinctiveElements.get(schema).values()); if (success) { result... | @Test public void testAbcd1() throws IOException { String xml = Resources.toString( Resources.getResource("response_schema/abcd1.xml"), StandardCharsets.UTF_8); OccurrenceSchemaType result = detector.detectSchema(xml); assertEquals(OccurrenceSchemaType.ABCD_1_2, result); }
@Test public void testAbcd2() throws IOExcepti... |
EsIndex { public static void swapIndexInAliases(EsConfig config, Set<String> aliases, String index) { Preconditions.checkArgument(aliases != null && !aliases.isEmpty(), "alias is required"); Preconditions.checkArgument(!Strings.isNullOrEmpty(index), "index is required"); swapIndexInAliases( config, aliases, index, Coll... | @Test(expected = IllegalArgumentException.class) public void swapIndexInAliasNullAliasTest() { EsIndex.swapIndexInAliases(EsConfig.from(DUMMY_HOST), null, "index_1"); thrown.expectMessage("aliases are required"); }
@Test(expected = IllegalArgumentException.class) public void swapIndexInAliasEmptyAliasTest() { EsIndex.s... |
UniqueGbifIdTransform { public UniqueGbifIdTransform run() { return useSyncMode ? runSync() : runAsync(); } UniqueGbifIdTransform run(); } | @Test public void skipFunctionTest() { final Map<String, ExtendedRecord> input = createErMap("1_1", "2_2", "3_3", "4_4"); final Map<String, BasicRecord> expected = createBrIdMap("1_1", "2_2", "3_3", "4_4"); UniqueGbifIdTransform gbifIdTransform = UniqueGbifIdTransform.builder() .erMap(input) .basicTransform(basicTransf... |
OccurrenceExtensionTransform extends DoFn<ExtendedRecord, ExtendedRecord> { public static SingleOutput<ExtendedRecord, ExtendedRecord> create() { return ParDo.of(new OccurrenceExtensionTransform()); } static SingleOutput<ExtendedRecord, ExtendedRecord> create(); void setCounterFn(SerializableConsumer<String> counterFn... | @Test public void extensionContainsOccurrenceTest() { String id = "1"; String somethingCore = "somethingCore"; String somethingExt = "somethingExt"; Map<String, String> ext1 = new HashMap<>(2); ext1.put(DwcTerm.occurrenceID.qualifiedName(), id); ext1.put(somethingExt, somethingExt); Map<String, String> ext2 = new HashM... |
CheckTransforms extends PTransform<PCollection<T>, PCollection<T>> { public static boolean checkRecordType(Set<String> types, InterpretationType... type) { boolean matchType = Arrays.stream(type).anyMatch(x -> types.contains(x.name())); boolean all = Arrays.stream(type).anyMatch(x -> types.contains(x.all())); return al... | @Test public void checkRecordTypeAllValueTest() { Set<String> set = Collections.singleton(RecordType.ALL.name()); boolean result = CheckTransforms.checkRecordType(set, RecordType.BASIC, RecordType.AUDUBON); Assert.assertTrue(result); }
@Test public void checkRecordTypeMatchValueTest() { Set<String> set = Collections.si... |
HashIdTransform extends DoFn<ExtendedRecord, ExtendedRecord> { public static SingleOutput<ExtendedRecord, ExtendedRecord> create(String datasetId) { return ParDo.of(new HashIdTransform(datasetId)); } static SingleOutput<ExtendedRecord, ExtendedRecord> create(String datasetId); @ProcessElement void processElement(@Elem... | @Test public void hashIdTest() { final String datasetId = "f349d447-1c92-4637-ab32-8ae559497032"; final List<ExtendedRecord> input = createCollection("0001_1", "0002_2", "0003_3"); final List<ExtendedRecord> expected = createCollection( "20d8ab138ab4c919cbf32f5d9e667812077a0ee4_1", "1122dc31ba32e386e3a36719699fdb5fb1d2... |
LocationTransform extends Transform<ExtendedRecord, LocationRecord> { @Override public SingleOutput<ExtendedRecord, LocationRecord> interpret() { return ParDo.of(this).withSideInputs(metadataView); } @Builder(buildMethodName = "create") private LocationTransform(
SerializableSupplier<KeyValueStore<LatLng, Geocod... | @Test public void emptyLrTest() { SerializableSupplier<KeyValueStore<LatLng, GeocodeResponse>> geocodeKvStore = () -> GeocodeKvStore.create(new KeyValueTestStoreStub<>()); ExtendedRecord er = ExtendedRecord.newBuilder().setId("777").build(); MetadataRecord mdr = MetadataRecord.newBuilder().setId("777").build(); PCollec... |
MetadataServiceClientFactory { public static SerializableSupplier<MetadataServiceClient> getInstanceSupplier( PipelinesConfig config) { return () -> getInstance(config); } @SneakyThrows private MetadataServiceClientFactory(PipelinesConfig config); static MetadataServiceClient getInstance(PipelinesConfig config); stati... | @Test public void sameLinkToObjectTest() { PipelinesConfig pc = new PipelinesConfig(); WsConfig wc = new WsConfig(); wc.setWsUrl("https: pc.setGbifApi(wc); SerializableSupplier<MetadataServiceClient> supplierOne = MetadataServiceClientFactory.getInstanceSupplier(pc); SerializableSupplier<MetadataServiceClient> supplier... |
MetadataServiceClientFactory { public static SerializableSupplier<MetadataServiceClient> createSupplier(PipelinesConfig config) { return () -> new MetadataServiceClientFactory(config).client; } @SneakyThrows private MetadataServiceClientFactory(PipelinesConfig config); static MetadataServiceClient getInstance(Pipeline... | @Test public void newObjectTest() { PipelinesConfig pc = new PipelinesConfig(); WsConfig wc = new WsConfig(); wc.setWsUrl("https: pc.setGbifApi(wc); SerializableSupplier<MetadataServiceClient> supplierOne = MetadataServiceClientFactory.createSupplier(pc); SerializableSupplier<MetadataServiceClient> supplierTwo = Metada... |
LocationFeatureInterpreter { public static BiConsumer<LocationRecord, LocationFeatureRecord> interpret( KeyValueStore<LatLng, String> kvStore) { return (lr, asr) -> { if (kvStore != null) { try { String json = kvStore.get(new LatLng(lr.getDecimalLatitude(), lr.getDecimalLongitude())); if (!Strings.isNullOrEmpty(json)) ... | @Test public void locationFeaturesInterpreterTest() { LocationRecord locationRecord = LocationRecord.newBuilder().setId("777").build(); LocationFeatureRecord record = LocationFeatureRecord.newBuilder().setId("777").build(); KeyValueStore<LatLng, String> kvStore = new KeyValueStore<LatLng, String>() { @Override public S... |
ImageInterpreter { public void interpret(ExtendedRecord er, ImageRecord mr) { Objects.requireNonNull(er); Objects.requireNonNull(mr); Result<Image> result = handler.convert(er); mr.setImageItems(result.getList()); mr.getIssues().setIssueList(result.getIssuesAsList()); } @Builder(buildMethodName = "create") private Ima... | @Test public void imageTest() { Map<String, String> ext1 = new HashMap<>(); ext1.put(DcTerm.identifier.qualifiedName(), "http: ext1.put(DcTerm.references.qualifiedName(), "http: ext1.put(DcTerm.created.qualifiedName(), "2010"); ext1.put(DcTerm.title.qualifiedName(), "Tt1"); ext1.put(DcTerm.description.qualifiedName(), ... |
MeasurementOrFactInterpreter { public void interpret(ExtendedRecord er, MeasurementOrFactRecord mfr) { Objects.requireNonNull(er); Objects.requireNonNull(mfr); Result<MeasurementOrFact> result = handler.convert(er); mfr.setMeasurementOrFactItems(result.getList()); mfr.getIssues().setIssueList(result.getIssuesAsList());... | @Test public void measurementOrFactTest() { String expected = "{\"id\": \"id\", \"created\": 0, \"measurementOrFactItems\": [{\"id\": \"Id1\", \"type\": \"Type1\", \"value\": \"1.5\", " + "\"accuracy\": \"Accurancy1\", \"unit\": \"Unit1\", \"determinedDate\": \"2010/2011\", \"determinedBy\": " + "\"By1\", \"method\": \... |
AudubonInterpreter { public void interpret(ExtendedRecord er, AudubonRecord ar) { Objects.requireNonNull(er); Objects.requireNonNull(ar); Result<Audubon> result = handler.convert(er); ar.setAudubonItems(result.getList()); ar.getIssues().setIssueList(result.getIssuesAsList()); } @Builder(buildMethodName = "create") priv... | @Test public void audubonTest() { String expected = "{\"id\": \"id\", \"created\": null, \"audubonItems\": [{\"creator\": \"Jose Padial\", " + "\"creatorUri\": null, \"providerLiteral\": \"CM\", \"provider\": null, \"metadataCreatorLiteral\": null, " + "\"metadataCreator\": null, \"metadataProviderLiteral\": null, \"me... |
BasicInterpreter { public static void interpretIndividualCount(ExtendedRecord er, BasicRecord br) { Consumer<Optional<Integer>> fn = parseResult -> { if (parseResult.isPresent()) { br.setIndividualCount(parseResult.get()); } else { addIssue(br, INDIVIDUAL_COUNT_INVALID); } }; SimpleTypeParser.parsePositiveInt(er, DwcTe... | @Test public void interpretIndividaulCountTest() { Map<String, String> coreMap = new HashMap<>(); coreMap.put(DwcTerm.individualCount.qualifiedName(), "2"); ExtendedRecord er = ExtendedRecord.newBuilder().setId(ID).setCoreTerms(coreMap).build(); BasicRecord br = BasicRecord.newBuilder().setId(ID).build(); BasicInterpre... |
BasicInterpreter { public static void interpretSampleSizeValue(ExtendedRecord er, BasicRecord br) { extractOptValue(er, DwcTerm.sampleSizeValue) .map(String::trim) .map(NumberParser::parseDouble) .filter(x -> !x.isInfinite() && !x.isNaN()) .ifPresent(br::setSampleSizeValue); } static BiConsumer<ExtendedRecord, BasicRe... | @Test public void interpretSampleSizeValueTest() { Map<String, String> coreMap = new HashMap<>(); coreMap.put(DwcTerm.sampleSizeValue.qualifiedName(), " value "); ExtendedRecord er = ExtendedRecord.newBuilder().setId(ID).setCoreTerms(coreMap).build(); BasicRecord br = BasicRecord.newBuilder().setId(ID).build(); BasicIn... |
BasicInterpreter { public static void interpretSampleSizeUnit(ExtendedRecord er, BasicRecord br) { extractOptValue(er, DwcTerm.sampleSizeUnit).map(String::trim).ifPresent(br::setSampleSizeUnit); } static BiConsumer<ExtendedRecord, BasicRecord> interpretGbifId(
HBaseLockingKeyService keygenService,
boolean ... | @Test public void interpretSampleSizeUnitTest() { Map<String, String> coreMap = new HashMap<>(); coreMap.put(DwcTerm.sampleSizeUnit.qualifiedName(), " value "); ExtendedRecord er = ExtendedRecord.newBuilder().setId(ID).setCoreTerms(coreMap).build(); BasicRecord br = BasicRecord.newBuilder().setId(ID).build(); BasicInte... |
BasicInterpreter { public static void interpretOrganismQuantity(ExtendedRecord er, BasicRecord br) { extractOptValue(er, DwcTerm.organismQuantity) .map(String::trim) .map(NumberParser::parseDouble) .filter(x -> !x.isInfinite() && !x.isNaN()) .ifPresent(br::setOrganismQuantity); } static BiConsumer<ExtendedRecord, Basi... | @Test public void interpretOrganismQuantityTest() { Map<String, String> coreMap = new HashMap<>(); coreMap.put(DwcTerm.organismQuantity.qualifiedName(), " value "); ExtendedRecord er = ExtendedRecord.newBuilder().setId(ID).setCoreTerms(coreMap).build(); BasicRecord br = BasicRecord.newBuilder().setId(ID).build(); Basic... |
BasicInterpreter { public static void interpretOrganismQuantityType(ExtendedRecord er, BasicRecord br) { extractOptValue(er, DwcTerm.organismQuantityType) .map(String::trim) .ifPresent(br::setOrganismQuantityType); } static BiConsumer<ExtendedRecord, BasicRecord> interpretGbifId(
HBaseLockingKeyService keygenSer... | @Test public void interpretOrganismQuantityTypeTest() { Map<String, String> coreMap = new HashMap<>(); coreMap.put(DwcTerm.organismQuantityType.qualifiedName(), " value "); ExtendedRecord er = ExtendedRecord.newBuilder().setId(ID).setCoreTerms(coreMap).build(); BasicRecord br = BasicRecord.newBuilder().setId(ID).build(... |
BasicInterpreter { public static void interpretRelativeOrganismQuantity(BasicRecord br) { if (!Strings.isNullOrEmpty(br.getOrganismQuantityType()) && !Strings.isNullOrEmpty(br.getSampleSizeUnit()) && br.getOrganismQuantityType().equalsIgnoreCase(br.getSampleSizeUnit())) { Double organismQuantity = br.getOrganismQuantit... | @Test public void interpretRelativeOrganismQuantityTest() { Map<String, String> coreMap = new HashMap<>(); coreMap.put(DwcTerm.sampleSizeValue.qualifiedName(), "2"); coreMap.put(DwcTerm.sampleSizeUnit.qualifiedName(), "some type "); coreMap.put(DwcTerm.organismQuantity.qualifiedName(), "10"); coreMap.put(DwcTerm.organi... |
BasicInterpreter { public static void interpretLicense(ExtendedRecord er, BasicRecord br) { String license = extractOptValue(er, DcTerm.license) .map(BasicInterpreter::getLicense) .map(License::name) .orElse(License.UNSPECIFIED.name()); br.setLicense(license); } static BiConsumer<ExtendedRecord, BasicRecord> interpret... | @Test public void interpretLicenseTest() { Map<String, String> coreMap = new HashMap<>(); coreMap.put( "http: ExtendedRecord er = ExtendedRecord.newBuilder().setId(ID).setCoreTerms(coreMap).build(); BasicRecord br = BasicRecord.newBuilder().setId(ID).build(); BasicInterpreter.interpretLicense(er, br); Assert.assertEqua... |
BasicInterpreter { public static void interpretBasisOfRecord(ExtendedRecord er, BasicRecord br) { Function<ParseResult<BasisOfRecord>, BasicRecord> fn = parseResult -> { if (parseResult.isSuccessful()) { br.setBasisOfRecord(parseResult.getPayload().name()); } else { br.setBasisOfRecord(BasisOfRecord.UNKNOWN.name()); ad... | @Test public void interpretBasisOfRecordTest() { Map<String, String> coreMap = new HashMap<>(); coreMap.put(DwcTerm.basisOfRecord.qualifiedName(), "LIVING_SPECIMEN"); ExtendedRecord er = ExtendedRecord.newBuilder().setId(ID).setCoreTerms(coreMap).build(); BasicRecord br = BasicRecord.newBuilder().setId(ID).build(); Bas... |
TemporalInterpreter implements Serializable { public void interpretDateIdentified(ExtendedRecord er, TemporalRecord tr) { if (hasValue(er, DwcTerm.dateIdentified)) { String value = extractValue(er, DwcTerm.dateIdentified); String normalizedValue = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(value)).orElse(va... | @Test public void testLikelyIdentified() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.year.qualifiedName(), "1879"); map.put(DwcTerm.month.qualifiedName(), "11 "); map.put(DwcTerm.day.qualifiedName(), "1"); map.put(DwcTerm.eventDate.qualifiedName(), "1.11.1879"); map.put(DcTerm.modified.qualifiedName(),... |
TemporalInterpreter implements Serializable { public void interpretModified(ExtendedRecord er, TemporalRecord tr) { if (hasValue(er, DcTerm.modified)) { String value = extractValue(er, DcTerm.modified); String normalizedValue = Optional.ofNullable(preprocessDateFn).map(x -> x.apply(value)).orElse(value); LocalDate uppe... | @Test public void testLikelyModified() { Map<String, String> map = new HashMap<>(); map.put(DwcTerm.year.qualifiedName(), "1879"); map.put(DwcTerm.month.qualifiedName(), "11 "); map.put(DwcTerm.day.qualifiedName(), "1"); map.put(DwcTerm.eventDate.qualifiedName(), "1.11.1879"); map.put(DwcTerm.dateIdentified.qualifiedNa... |
EsIndex { public static long countDocuments(EsConfig config, String index) { Preconditions.checkArgument(!Strings.isNullOrEmpty(index), "index is required"); log.info("Counting documents from index {}", index); try (EsClient esClient = EsClient.from(config)) { return EsService.countIndexDocuments(esClient, index); } } ... | @Test(expected = IllegalArgumentException.class) public void countIndexDocumentsNullIndexTest() { EsIndex.countDocuments(EsConfig.from(DUMMY_HOST), null); thrown.expectMessage("index is required"); }
@Test(expected = IllegalArgumentException.class) public void countIndexDocumentsEmptyIndexTest() { EsIndex.countDocument... |
SwitchOperationsService implements ILinkOperationsServiceCarrier { public Switch updateSwitchUnderMaintenanceFlag(SwitchId switchId, boolean underMaintenance) throws SwitchNotFoundException { return transactionManager.doInTransaction(() -> { Optional<Switch> foundSwitch = switchRepository.findById(switchId); if (!(foun... | @Test public void shouldUpdateLinkUnderMaintenanceFlag() throws SwitchNotFoundException { Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build(); switchRepository.add(sw); switchOperationsService.updateSwitchUnderMaintenanceFlag(TEST_SWITCH_ID, true); sw = switchRepository.findById(TE... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIntermediateIngressRule(DatapathId dpid, int port) throws SwitchOperationException { IOFSwitch sw = lookupSwitch(dpid); OFFlowMod flowMod = buildIntermediateIngressRule(dpid, port); String f... | @Test public void installIntermediateIngressRule() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installIntermediateIngressRule(dpid, 1); OFFlowMod result = capture.getValue(); assertEquals(scheme.installIntermediateIngressRule(dpid, 1), result); } |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installPreIngressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE... | @Test public void installPreIngressTablePassThroughDefaultRule() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installPreIngressTablePassThroughDefaultRule(dpid); OFFlowMod result = capture.getValue(); assertEquals(scheme.installPreIngressTablePassThroughDefaultRule(dpid), resul... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installEgressTablePassThroughDefaultRule(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getTablePassThroughDefaultFlowGenerator( MULTITABLE_EGR... | @Test public void installEgressTablePassThroughDefaultRule() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installEgressTablePassThroughDefaultRule(dpid); OFFlowMod result = capture.getValue(); assertEquals(scheme.installEgressTablePassThroughDefaultRule(dpid), result); } |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installRoundTripLatencyFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getRoundTripLatencyFlowGenerator(), "--RoundTripLatencyRule--"); } ... | @Test public void installRoundTripLatencyFlow() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installRoundTripLatencyFlow(dpid); OFFlowMod result = capture.getValue(); assertEquals(scheme.installRoundTripLatencyRule(dpid), result); } |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installBfdCatchFlow(DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getBfdCatchFlowGenerator(), "--CatchBfdRule--"); } @Override Collection<Cla... | @Test public void installBfdCatchFlow() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installBfdCatchFlow(defaultDpid); assertEquals(scheme.installBfdCatchRule(defaultDpid), capture.getValue()); } |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public Long installUnicastVerificationRuleVxlan(final DatapathId dpid) throws SwitchOperationException { return installDefaultFlow(dpid, switchFlowFactory.getUnicastVerificationVxlanFlowGenerator(), "--Verific... | @Test public void installUnicastVerificationRuleVxlan() throws Exception { mockGetMetersRequest(Lists.newArrayList(broadcastMeterId), true, 10L); mockBarrierRequest(); expect(iofSwitch.write(anyObject(OFMeterMod.class))).andReturn(true).times(1); Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.insta... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installIngressFlow(DatapathId dpid, DatapathId dstDpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int transitTunnelId, OutputVlanType outputVlanType, long meterId,... | @Test public void installIngressFlowReplaceActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installIngressFlow(dpid, EGRESS_SWITCH_DP_ID, cookieHex, cookie, inputPort, outputPort,... |
FlowOperationsService { public Flow updateFlow(FlowOperationsCarrier carrier, FlowPatch flowPatch) throws FlowNotFoundException { UpdateFlowResult updateFlowResult = transactionManager.doInTransaction(() -> { Optional<Flow> foundFlow = flowRepository.findById(flowPatch.getFlowId()); if (!foundFlow.isPresent()) { return... | @Test public void shouldUpdateMaxLatencyPriorityAndPinnedFlowFields() throws FlowNotFoundException { String testFlowId = "flow_id"; Long maxLatency = 555L; Integer priority = 777; PathComputationStrategy pathComputationStrategy = PathComputationStrategy.LATENCY; String description = "new_description"; Flow flow = new T... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installEgressFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, int outputVlanId, OutputVlanType outputVlanType, FlowEncapsulationType encapsulati... | @Test public void installEgressFlowNoneActionUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installEgressFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, 0, OutputV... |
FlowOperationsService { @VisibleForTesting UpdateFlowResult.UpdateFlowResultBuilder prepareFlowUpdateResult(FlowPatch flowPatch, Flow flow) { boolean updateRequired = updateRequiredByPathComputationStrategy(flowPatch, flow); updateRequired |= updateRequiredBySource(flowPatch, flow); updateRequired |= updateRequiredByDe... | @Test public void shouldPrepareFlowUpdateResultWithChangedStrategy() { String flowId = "test_flow_id"; FlowPatch flowDto = FlowPatch.builder() .flowId(flowId) .maxLatency(100L) .pathComputationStrategy(PathComputationStrategy.COST) .build(); Flow flow = Flow.builder() .flowId(flowId) .srcSwitch(Switch.builder().switchI... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installTransitFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int transitTunnelId, FlowEncapsulationType encapsulationType, boolean multiTable) throws SwitchOperati... | @Test public void installTransitFlowUsingTransitVlan() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN; switchManager.installTransitFlow(dpid, cookieHex, cookie, inputPort, outputPort, transitVlanId, encapsulationType,... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public long installOneSwitchFlow(DatapathId dpid, String flowId, Long cookie, int inputPort, int outputPort, int inputVlanId, int outputVlanId, OutputVlanType outputVlanType, long meterId, boolean multiTable) ... | @Test public void installOneSwitchFlowReplaceAction() throws Exception { Capture<OFFlowMod> capture = prepareForInstallTest(); switchManager.installOneSwitchFlow(dpid, cookieHex, cookie, inputPort, outputPort, inputVlanId, outputVlanId, OutputVlanType.REPLACE, meterId, false); assertEquals( scheme.oneSwitchReplaceFlowM... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFFlowStatsEntry> dumpFlowTable(final DatapathId dpid) throws SwitchNotFoundException { List<OFFlowStatsEntry> entries = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); OFFactory ofFactory = ... | @Test public void dumpFlowTable() { } |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<OFMeterConfig> dumpMeters(final DatapathId dpid) throws SwitchOperationException { List<OFMeterConfig> result = new ArrayList<>(); IOFSwitch sw = lookupSwitch(dpid); if (sw == null) { throw new Ill... | @Test public void dumpMeters() throws InterruptedException, ExecutionException, TimeoutException, SwitchOperationException { OFMeterConfig firstMeter = ofFactory.buildMeterConfig().setMeterId(1).build(); OFMeterConfig secondMeter = ofFactory.buildMeterConfig().setMeterId(2).build(); ListenableFuture<List<OFMeterConfigS... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public void deleteMeter(final DatapathId dpid, final long meterId) throws SwitchOperationException { if (meterId > 0L) { IOFSwitch sw = lookupSwitch(dpid); verifySwitchSupportsMeters(sw); buildAndDeleteMeter(s... | @Test public void deleteMeter() throws Exception { mockBarrierRequest(); final Capture<OFMeterMod> capture = prepareForMeterTest(); switchManager.deleteMeter(dpid, meterId); final OFMeterMod meterMod = capture.getValue(); assertEquals(meterMod.getCommand(), OFMeterModCommand.DELETE); assertEquals(meterMod.getMeterId(),... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteAllNonDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid); IOFSwitch sw = lookupSwitch(dpid); OFFactory of... | @Test public void shouldDeleteAllNonDefaultRules() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); C... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteDefaultRules(DatapathId dpid, List<Integer> islPorts, List<Integer> flowPorts, Set<Integer> flowLldpPorts, Set<Integer> flowArpPorts, Set<Integer> server42FlowRttPorts, boolean multiTab... | @Test public void shouldDeleteDefaultRulesWithoutMeters() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(new OFFactoryVer12Mock()); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getId... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException { List<OFFlowStatsEntry> flowStatsBefore = dumpF... | @Test public void shouldDeleteRuleByCookie() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); mockFlowStatsRequest(cookie, DROP_RULE_COOKIE, VERIFICATION_BROADCAST_RULE_COOKIE, VERIFICATION_UNICAST_RULE_COOKIE); Capture... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting void processMeter(IOFSwitch sw, OFMeterMod meterMod) { long meterId = meterMod.getMeterId(); OFMeterConfig meterConfig; try { meterConfig = getMeter(sw.getId(), meterId); } catch (SwitchOperationExcep... | @Test public void shouldInstallMeterWithKbpsFlag() throws Exception { expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription); expect(iofSwitch.getId()).andStubReturn(dpid... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @Override public List<Long> installDefaultRules(final DatapathId dpid) throws SwitchOperationException { List<Long> rules = new ArrayList<>(); rules.add(installDropFlow(dpid)); rules.add(installVerificationRule(dpid, tr... | @Test public void shouldNotInstallMetersIfAlreadyExists() throws Exception { long expectedRate = config.getBroadcastRateLimit(); expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch); expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory); expect(iofSwitch.getSwitchDescription()).andStubReturn(switc... |
SwitchManager implements IFloodlightModule, IFloodlightService, ISwitchManager, IOFMessageListener { @VisibleForTesting boolean validateRoundTripLatencyGroup(DatapathId dpId, OFGroupDescStatsEntry groupDesc) { return groupDesc.getBuckets().size() == 2 && validateRoundTripSendToControllerBucket(dpId, groupDesc.getBucket... | @Test public void validateRoundTripLatencyGroup() { OFGroupAdd groupAdd = getOfGroupAddInstruction(); assertTrue(runValidateRoundTripLatencyGroup(groupAdd.getBuckets())); } |
StatsCollector extends Thread { void sendStats(FlowLatencyPacketBucket flowLatencyPacketBucket) throws InvalidProtocolBufferException { long currentTimeMillis = System.currentTimeMillis(); for (FlowLatencyPacket packet : flowLatencyPacketBucket.getPacketList()) { FlowRttStatsData data = new FlowRttStatsData( packet.get... | @Test public void sendStatsTest() throws Exception { Builder bucketBuilder = FlowLatencyPacketBucket.newBuilder(); FlowLatencyPacket packet1 = FlowLatencyPacket.newBuilder() .setFlowId("some-flow-id-1") .setDirection(false) .setT0(100) .setT1(150) .setPacketId(1).build(); FlowLatencyPacket packet2 = FlowLatencyPacket.n... |
Gate { @KafkaHandler void listen(@Payload AddFlow data, @Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) String switchIdKey) { SwitchId switchId = new SwitchId(switchIdKey); Builder builder = CommandPacket.newBuilder(); Flow flow = Flow.newBuilder() .setFlowId(data.getFlowId()) .setEncapsulationType(EncapsulationType.forNumb... | @Test public void addFlow() throws Exception { AddFlow addFlow = AddFlow.builder() .flowId("some-flow-id") .encapsulationType(EncapsulationType.VLAN) .tunnelId(1001L) .direction(FlowDirection.REVERSE) .port(42) .build(); String switchId = "00:00:1b:45:18:d6:71:5a"; gate.listen(addFlow, switchId); CommandPacket commandP... |
SpeakerBolt extends BaseRichBolt { protected List<Values> addSwitch(AddSwitchCommand data) throws Exception { List<Values> values = new ArrayList<>(); SwitchId dpid = data.getDpid(); if (switches.get(dpid) == null) { ISwitchImpl sw = new ISwitchImpl(dpid, data.getNumOfPorts(), PortStateType.DOWN); switches.put(new Swit... | @Test public void addSwitch() throws Exception { speakerBolt.addSwitch(switchMessage); assertEquals(1, speakerBolt.switches.size()); ISwitchImpl sw = speakerBolt.switches.get(dpid); assertTrue(sw.isActive()); List<IPortImpl> ports = sw.getPorts(); assertEquals(numOfPorts, ports.size()); for (IPortImpl port : ports) { i... |
ISwitchImpl implements ISwitch { @Override public void modState(SwitchChangeType state) throws SimulatorException { this.state = state; switch (state) { case ADDED: break; case ACTIVATED: activate(); break; case DEACTIVATED: case REMOVED: deactivate(); break; case CHANGED: throw new SimulatorException("Received modStat... | @Test public void modState() throws Exception { sw.modState(SwitchChangeType.ACTIVATED); assertTrue(sw.isActive()); sw.modState(SwitchChangeType.DEACTIVATED); assertFalse(sw.isActive()); } |
ISwitchImpl implements ISwitch { @Override public void setDpid(DatapathId dpid) { this.dpid = dpid; } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate();... | @Test public void testSetDpid() { SwitchId newDpid = new SwitchId("01:02:03:04:05:06"); sw.setDpid(newDpid); assertEquals(newDpid.toString(), sw.getDpidAsString()); assertEquals(DatapathId.of(newDpid.toString()), sw.getDpid()); DatapathId dpid = sw.getDpid(); sw.setDpid(dpid); assertEquals(dpid, sw.getDpid()); } |
ISwitchImpl implements ISwitch { @Override public int addPort(IPortImpl port) throws SimulatorException { if (ports.size() < maxPorts) { ports.add(port); } else { throw new SimulatorException(String.format("Switch already has reached maxPorts of %d" + "", maxPorts)); } return port.getNumber(); } ISwitchImpl(); ISwitch... | @Test public void addPort() throws Exception { int portNum = sw.getPorts().size(); IPortImpl port = new IPortImpl(sw, PortStateType.UP, portNum); thrown.expect(SimulatorException.class); thrown.expectMessage("Switch already has reached maxPorts"); sw.addPort(port); } |
ISwitchImpl implements ISwitch { @Override public IPortImpl getPort(int portNum) throws SimulatorException { try { return ports.get(portNum); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Port %d is not defined on %s", portNum, getDpidAsString())); } } ISwitchImpl(); ISwitchImpl(S... | @Test public void getPort() throws Exception { int numOfPorts = sw.getPorts().size(); assertEquals(1, sw.getPort(1).getNumber()); thrown.expect(SimulatorException.class); thrown.expectMessage(String.format("Port %d is not defined on %s", numOfPorts, sw.getDpidAsString())); sw.getPort(numOfPorts); } |
ISwitchImpl implements ISwitch { @Override public IFlow getFlow(long cookie) throws SimulatorException { try { return flows.get(cookie); } catch (IndexOutOfBoundsException e) { throw new SimulatorException(String.format("Flow %d could not be found.", cookie)); } } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImp... | @Test public void getFlow() { } |
ISwitchImpl implements ISwitch { @Override public void addFlow(IFlow flow) throws SimulatorException { if (flows.containsKey(flow.getCookie())) { throw new SimulatorException(String.format("Flow %s already exists.", flow.toString())); } flows.put(flow.getCookie(), flow); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); I... | @Test public void addFlow() { } |
ISwitchImpl implements ISwitch { @Override public void modFlow(IFlow flow) throws SimulatorException { delFlow(flow.getCookie()); addFlow(flow); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override ... | @Test public void modFlow() { } |
ISwitchImpl implements ISwitch { @Override public void delFlow(long cookie) { flows.remove(cookie); } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate();... | @Test public void delFlow() { } |
ISwitchImpl implements ISwitch { @Override public List<PortStatsEntry> getPortStats() { return null; } ISwitchImpl(); ISwitchImpl(SwitchId dpid); ISwitchImpl(SwitchId dpid, int numOfPorts, PortStateType portState); @Override void modState(SwitchChangeType state); @Override void activate(); @Override void deactivate()... | @Test public void getPortStats() { } |
IPortImpl implements IPort { @Override public boolean isActiveIsl() { return (peerSwitch != null && peerPortNum >= 0 && isActive && isForwarding); } IPortImpl(ISwitchImpl sw, PortStateType state, int portNumber); InfoMessage makePorChangetMessage(); @Override void enable(); @Override void disable(); @Override void bloc... | @Test public void isActiveIsl() throws Exception { port.enable(); port.setPeerSwitch("00:00:00:00:00:01"); port.setPeerPortNum(10); assertTrue(port.isActiveIsl()); port.disable(); assertFalse(port.isActiveIsl()); port.enable(); port.block(); assertFalse(port.isActiveIsl()); port.unblock(); assertTrue(port.isActiveIsl()... |
IPortImpl implements IPort { @Override public PortStatsEntry getStats() { if (isForwarding && isActive) { this.rxPackets += rand.nextInt(MAX_LARGE); this.txPackets += rand.nextInt(MAX_LARGE); this.rxBytes += rand.nextInt(MAX_LARGE); this.txBytes += rand.nextInt(MAX_LARGE); this.rxDropped += rand.nextInt(MAX_SMALL); thi... | @Test public void getStats() throws Exception { } |
OpenTsdbTopology extends AbstractTopology<OpenTsdbTopologyConfig> { @Override public StormTopology createTopology() { logger.info("Creating OpenTsdbTopology - {}", topologyName); TopologyBuilder tb = new TopologyBuilder(); attachInput(tb); OpenTsdbConfig openTsdbConfig = topologyConfig.getOpenTsdbConfig(); tb.setBolt(O... | @Test public void shouldSuccessfulSendDatapoint() { Datapoint datapoint = new Datapoint("metric", timestamp, Collections.emptyMap(), 123); MockedSources sources = new MockedSources(); Testing.withTrackedCluster(clusterParam, (cluster) -> { OpenTsdbTopology topology = new OpenTsdbTopology(makeLaunchEnvironment()); sourc... |
CommandBuilderImpl implements CommandBuilder { @Override public List<BaseFlow> buildCommandsToSyncMissingRules(SwitchId switchId, List<Long> switchRules) { List<BaseFlow> commands = new ArrayList<>(buildInstallDefaultRuleCommands(switchId, switchRules)); commands.addAll(buildInstallFlowSharedRuleCommands(switchId, swit... | @Test public void testCommandBuilder() { List<BaseFlow> response = commandBuilder .buildCommandsToSyncMissingRules(SWITCH_ID_B, Stream.of(1L, 2L, 3L, 4L) .map(effectiveId -> new FlowSegmentCookie(FlowPathDirection.FORWARD, effectiveId)) .map(Cookie::getValue) .collect(Collectors.toList())); assertEquals(4, response.siz... |
CommandBuilderImpl implements CommandBuilder { @VisibleForTesting RemoveFlow buildRemoveFlowWithoutMeterFromFlowEntry(SwitchId switchId, FlowEntry entry) { Optional<FlowMatchField> entryMatch = Optional.ofNullable(entry.getMatch()); Optional<FlowInstructions> instructions = Optional.ofNullable(entry.getInstructions());... | @Test public void shouldBuildRemoveFlowWithoutMeterFromFlowEntryWithTransitVlanEncapsulation() { Long cookie = new FlowSegmentCookie(FlowPathDirection.FORWARD, 1).getValue(); String inPort = "1"; String inVlan = "10"; String outPort = "2"; FlowEntry flowEntry = buildFlowEntry(cookie, inPort, inVlan, outPort, null, fals... |
SwitchValidateServiceImpl implements SwitchValidateService { @Override public void handleFlowEntriesResponse(String key, SwitchFlowEntries data) { handle(key, SwitchValidateEvent.RULES_RECEIVED, SwitchValidateContext.builder().flowEntries(data.getFlowEntries()).build()); } SwitchValidateServiceImpl(
SwitchM... | @Test public void receiveOnlyRules() { handleRequestAndInitDataReceive(); service.handleFlowEntriesResponse(KEY, new SwitchFlowEntries(SWITCH_ID, singletonList(flowEntry))); verifyNoMoreInteractions(carrier); verifyNoMoreInteractions(validationService); }
@Test public void doNothingWhenFsmNotFound() { service.handleFlo... |
FlowOperationsService { public Collection<Flow> getFlowsForEndpoint(SwitchId switchId, Integer port) throws SwitchNotFoundException { flowDashboardLogger.onFlowPathsDumpByEndpoint(switchId, port); if (!switchRepository.findById(switchId).isPresent()) { throw new SwitchNotFoundException(switchId); } if (port != null) { ... | @Test public void getFlowsForEndpointNotReturnFlowsForOrphanedPaths() throws SwitchNotFoundException { Switch switchA = createSwitch(SWITCH_ID_1); Switch switchB = createSwitch(SWITCH_ID_2); Switch switchC = createSwitch(SWITCH_ID_3); Switch switchD = createSwitch(SWITCH_ID_4); Flow flow = createFlow(FLOW_ID_1, switchA... |
SwitchValidateServiceImpl implements SwitchValidateService { @Override public void handleSwitchValidateRequest(String key, SwitchValidateRequest request) { SwitchValidateFsm fsm = builder.newStateMachine( SwitchValidateState.START, carrier, key, request, validationService, repositoryFactory); fsms.put(key, fsm); fsm.st... | @Test public void errorResponseOnSwitchNotFound() { request = SwitchValidateRequest .builder().switchId(SWITCH_ID_MISSING).performSync(true).processMeters(true).build(); service.handleSwitchValidateRequest(KEY, request); verify(carrier).cancelTimeoutCallback(eq(KEY)); verify(carrier).errorResponse( eq(KEY), eq(ErrorTyp... |
ValidationServiceImpl implements ValidationService { @Override public ValidateRulesResult validateRules(SwitchId switchId, List<FlowEntry> presentRules, List<FlowEntry> expectedDefaultRules) { log.debug("Validating rules on switch {}", switchId); Set<Long> expectedCookies = getExpectedFlowRules(switchId); return makeRu... | @Test public void validateRulesEmpty() throws SwitchNotFoundException { ValidationService validationService = new ValidationServiceImpl(persistenceManager().build(), topologyConfig); ValidateRulesResult response = validationService.validateRules(SWITCH_ID_A, emptyList(), emptyList()); assertTrue(response.getMissingRule... |
ValidationServiceImpl implements ValidationService { private void validateDefaultRules(List<FlowEntry> presentRules, List<FlowEntry> expectedDefaultRules, Set<Long> missingRules, Set<Long> properRules, Set<Long> excessRules, Set<Long> misconfiguredRules) { List<FlowEntry> presentDefaultRules = presentRules.stream() .fi... | @Test public void validateDefaultRules() throws SwitchNotFoundException { ValidationService validationService = new ValidationServiceImpl(persistenceManager().build(), topologyConfig); List<FlowEntry> flowEntries = Lists.newArrayList(FlowEntry.builder().cookie(0x8000000000000001L).priority(1).byteCount(123).build(), Fl... |
SwitchSyncServiceImpl implements SwitchSyncService { @Override public void handleSwitchSync(String key, SwitchValidateRequest request, ValidationResult validationResult) { SwitchSyncFsm fsm = builder.newStateMachine(SwitchSyncState.INITIALIZED, carrier, key, commandBuilder, request, validationResult); process(fsm); } S... | @Test public void handleNothingRulesToSync() { missingRules = emptyList(); service.handleSwitchSync(KEY, request, makeValidationResult()); verify(carrier).response(eq(KEY), any(InfoMessage.class)); verify(carrier).cancelTimeoutCallback(eq(KEY)); verifyNoMoreInteractions(commandBuilder); verifyNoMoreInteractions(carrier... |
SwitchSyncServiceImpl implements SwitchSyncService { @Override public void handleInstallRulesResponse(String key) { SwitchSyncFsm fsm = fsms.get(key); if (fsm == null) { logFsmNotFound(key); return; } fsm.fire(SwitchSyncEvent.RULES_INSTALLED); process(fsm); } SwitchSyncServiceImpl(SwitchManagerCarrier carrier, Persiste... | @Test public void doNothingWhenFsmNotFound() { service.handleInstallRulesResponse(KEY); verifyZeroInteractions(carrier); verifyZeroInteractions(commandBuilder); } |
FlowPathStatusConverter implements AttributeConverter<FlowPathStatus, String> { @Override public String toGraphProperty(FlowPathStatus value) { if (value == null) { return null; } return value.name().toLowerCase(); } @Override String toGraphProperty(FlowPathStatus value); @Override FlowPathStatus toEntityAttribute(Str... | @Test public void shouldConvertToGraphProperty() { FlowPathStatusConverter converter = new FlowPathStatusConverter(); assertEquals("active", converter.toGraphProperty(FlowPathStatus.ACTIVE)); assertEquals("inactive", converter.toGraphProperty(FlowPathStatus.INACTIVE)); assertEquals("in_progress", converter.toGraphPrope... |
FlowPathStatusConverter implements AttributeConverter<FlowPathStatus, String> { @Override public FlowPathStatus toEntityAttribute(String value) { if (value == null || value.trim().isEmpty()) { return null; } return FlowPathStatus.valueOf(value.toUpperCase()); } @Override String toGraphProperty(FlowPathStatus value); @... | @Test public void shouldConvertToEntity() { FlowPathStatusConverter converter = new FlowPathStatusConverter(); assertEquals(FlowPathStatus.ACTIVE, converter.toEntityAttribute("ACTIVE")); assertEquals(FlowPathStatus.ACTIVE, converter.toEntityAttribute("active")); assertEquals(FlowPathStatus.IN_PROGRESS, converter.toEnti... |
PathIdConverter implements AttributeConverter<PathId, String> { @Override public String toGraphProperty(PathId value) { if (value == null) { return null; } return value.getId(); } @Override String toGraphProperty(PathId value); @Override PathId toEntityAttribute(String value); static final PathIdConverter INSTANCE; } | @Test public void shouldConvertIdToString() { PathId pathId = new PathId("test_path_id"); String graphObject = PathIdConverter.INSTANCE.toGraphProperty(pathId); assertEquals(pathId.getId(), graphObject); } |
PathIdConverter implements AttributeConverter<PathId, String> { @Override public PathId toEntityAttribute(String value) { if (value == null || value.trim().isEmpty()) { return null; } return new PathId(value); } @Override String toGraphProperty(PathId value); @Override PathId toEntityAttribute(String value); static fi... | @Test public void shouldConvertStringToId() { PathId pathId = new PathId("test_path_id"); PathId actualEntity = PathIdConverter.INSTANCE.toEntityAttribute(pathId.getId()); assertEquals(pathId, actualEntity); } |
SwitchIdConverter implements AttributeConverter<SwitchId, String> { @Override public String toGraphProperty(SwitchId value) { if (value == null) { return null; } return value.toString(); } @Override String toGraphProperty(SwitchId value); @Override SwitchId toEntityAttribute(String value); static final SwitchIdConvert... | @Test public void shouldConvertIdToString() { SwitchId switchId = new SwitchId((long) 0x123); String graphObject = SwitchIdConverter.INSTANCE.toGraphProperty(switchId); assertEquals(switchId.toString(), graphObject); } |
SwitchIdConverter implements AttributeConverter<SwitchId, String> { @Override public SwitchId toEntityAttribute(String value) { if (value == null || value.trim().isEmpty()) { return null; } return new SwitchId(value); } @Override String toGraphProperty(SwitchId value); @Override SwitchId toEntityAttribute(String value... | @Test public void shouldConvertStringToId() { SwitchId switchId = new SwitchId((long) 0x123); SwitchId actualEntity = SwitchIdConverter.INSTANCE.toEntityAttribute(switchId.toString()); assertEquals(switchId, actualEntity); } |
FlowStatusConverter implements AttributeConverter<FlowStatus, String> { @Override public String toGraphProperty(FlowStatus value) { if (value == null) { return null; } return value.name().toLowerCase(); } @Override String toGraphProperty(FlowStatus value); @Override FlowStatus toEntityAttribute(String value); static f... | @Test public void shouldConvertToGraphProperty() { FlowStatusConverter converter = FlowStatusConverter.INSTANCE; assertEquals("up", converter.toGraphProperty(FlowStatus.UP)); assertEquals("down", converter.toGraphProperty(FlowStatus.DOWN)); assertEquals("in_progress", converter.toGraphProperty(FlowStatus.IN_PROGRESS));... |
FlowStatusConverter implements AttributeConverter<FlowStatus, String> { @Override public FlowStatus toEntityAttribute(String value) { if (value == null || value.trim().isEmpty()) { return FlowStatus.UP; } return FlowStatus.valueOf(value.toUpperCase()); } @Override String toGraphProperty(FlowStatus value); @Override Fl... | @Test public void shouldConvertToEntity() { FlowStatusConverter converter = FlowStatusConverter.INSTANCE; assertEquals(FlowStatus.UP, converter.toEntityAttribute("UP")); assertEquals(FlowStatus.UP, converter.toEntityAttribute("up")); assertEquals(FlowStatus.IN_PROGRESS, converter.toEntityAttribute("In_Progress")); } |
ExclusionCookieConverter implements AttributeConverter<ExclusionCookie, Long> { @Override public Long toGraphProperty(ExclusionCookie value) { if (value == null) { return null; } return value.getValue(); } @Override Long toGraphProperty(ExclusionCookie value); @Override ExclusionCookie toEntityAttribute(Long value); s... | @Test public void shouldConvertIdToLong() { ExclusionCookie cookie = new ExclusionCookie((long) 0x123); Long graphObject = new ExclusionCookieConverter().toGraphProperty(cookie); assertEquals(cookie.getValue(), (long) graphObject); } |
ExclusionCookieConverter implements AttributeConverter<ExclusionCookie, Long> { @Override public ExclusionCookie toEntityAttribute(Long value) { if (value == null) { return null; } return new ExclusionCookie(value); } @Override Long toGraphProperty(ExclusionCookie value); @Override ExclusionCookie toEntityAttribute(Lo... | @Test public void shouldConvertLongToId() { ExclusionCookie cookie = new ExclusionCookie((long) 0x123); Cookie actualEntity = new ExclusionCookieConverter().toEntityAttribute(cookie.getValue()); assertEquals(cookie, actualEntity); } |
SwitchOperationsService implements ILinkOperationsServiceCarrier { public boolean deleteSwitch(SwitchId switchId, boolean force) throws SwitchNotFoundException { transactionManager.doInTransaction(() -> { Switch sw = switchRepository.findById(switchId) .orElseThrow(() -> new SwitchNotFoundException(switchId)); switchPr... | @Test public void shouldDeletePortPropertiesWhenDeletingSwitch() throws SwitchNotFoundException { Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build(); switchRepository.add(sw); PortProperties portProperties = PortProperties.builder().switchObj(sw).port(7).discoveryEnabled(false).bu... |
FlowSegmentCookieConverter implements AttributeConverter<FlowSegmentCookie, Long> { @Override public Long toGraphProperty(FlowSegmentCookie value) { if (value == null) { return null; } return value.getValue(); } @Override Long toGraphProperty(FlowSegmentCookie value); @Override FlowSegmentCookie toEntityAttribute(Long... | @Test public void shouldConvertIdToLong() { FlowSegmentCookie cookie = new FlowSegmentCookie((long) 0x123); Long graphObject = FlowSegmentCookieConverter.INSTANCE.toGraphProperty(cookie); assertEquals(cookie.getValue(), (long) graphObject); } |
FlowSegmentCookieConverter implements AttributeConverter<FlowSegmentCookie, Long> { @Override public FlowSegmentCookie toEntityAttribute(Long value) { if (value == null) { return null; } return new FlowSegmentCookie(value); } @Override Long toGraphProperty(FlowSegmentCookie value); @Override FlowSegmentCookie toEntity... | @Test public void shouldConvertLongToId() { FlowSegmentCookie cookie = new FlowSegmentCookie((long) 0x123); FlowSegmentCookie actualEntity = FlowSegmentCookieConverter.INSTANCE.toEntityAttribute(cookie.getValue()); assertEquals(cookie, actualEntity); } |
SwitchStatusConverter implements AttributeConverter<SwitchStatus, String> { @Override public String toGraphProperty(SwitchStatus value) { if (value == null) { return null; } return value.name().toLowerCase(); } @Override String toGraphProperty(SwitchStatus value); @Override SwitchStatus toEntityAttribute(String value)... | @Test public void shouldConvertToGraphProperty() { SwitchStatusConverter converter = SwitchStatusConverter.INSTANCE; assertEquals("active", converter.toGraphProperty(SwitchStatus.ACTIVE)); assertEquals("inactive", converter.toGraphProperty(SwitchStatus.INACTIVE)); } |
SwitchStatusConverter implements AttributeConverter<SwitchStatus, String> { @Override public SwitchStatus toEntityAttribute(String value) { if (value == null || value.trim().isEmpty()) { return null; } return SwitchStatus.valueOf(value.toUpperCase()); } @Override String toGraphProperty(SwitchStatus value); @Override S... | @Test public void shouldConvertToEntity() { SwitchStatusConverter converter = SwitchStatusConverter.INSTANCE; assertEquals(SwitchStatus.ACTIVE, converter.toEntityAttribute("ACTIVE")); assertEquals(SwitchStatus.ACTIVE, converter.toEntityAttribute("active")); assertEquals(SwitchStatus.INACTIVE, converter.toEntityAttribut... |
FlowEncapsulationTypeConverter implements AttributeConverter<FlowEncapsulationType, String> { @Override public String toGraphProperty(FlowEncapsulationType value) { if (value == null) { return null; } return value.name(); } @Override String toGraphProperty(FlowEncapsulationType value); @Override FlowEncapsulationType ... | @Test public void shouldConvertToGraphProperty() { assertEquals("TRANSIT_VLAN", FlowEncapsulationTypeConverter.INSTANCE.toGraphProperty(FlowEncapsulationType.TRANSIT_VLAN)); } |
FlowEncapsulationTypeConverter implements AttributeConverter<FlowEncapsulationType, String> { @Override public FlowEncapsulationType toEntityAttribute(String value) { if (value == null || value.trim().isEmpty()) { return null; } return FlowEncapsulationType.valueOf(value); } @Override String toGraphProperty(FlowEncaps... | @Test public void shouldConvertToEntity() { assertEquals(FlowEncapsulationType.TRANSIT_VLAN, FlowEncapsulationTypeConverter.INSTANCE.toEntityAttribute("TRANSIT_VLAN")); } |
MeterIdConverter implements AttributeConverter<MeterId, Long> { @Override public Long toGraphProperty(MeterId value) { if (value == null) { return null; } return value.getValue(); } @Override Long toGraphProperty(MeterId value); @Override MeterId toEntityAttribute(Long value); static final MeterIdConverter INSTANCE; } | @Test public void shouldConvertIdToString() { MeterId meterId = new MeterId(0x123); Long graphObject = MeterIdConverter.INSTANCE.toGraphProperty(meterId); assertEquals(meterId.getValue(), (long) graphObject); } |
MeterIdConverter implements AttributeConverter<MeterId, Long> { @Override public MeterId toEntityAttribute(Long value) { if (value == null) { return null; } return new MeterId(value); } @Override Long toGraphProperty(MeterId value); @Override MeterId toEntityAttribute(Long value); static final MeterIdConverter INSTANC... | @Test public void shouldConvertStringToId() { MeterId meterId = new MeterId(0x123); MeterId actualEntity = MeterIdConverter.INSTANCE.toEntityAttribute(meterId.getValue()); assertEquals(meterId, actualEntity); } |
IslStatusConverter implements AttributeConverter<IslStatus, String> { @Override public String toGraphProperty(IslStatus value) { if (value == null) { return null; } return value.name().toLowerCase(); } @Override String toGraphProperty(IslStatus value); @Override IslStatus toEntityAttribute(String value); static final ... | @Test public void shouldConvertToGraphProperty() { IslStatusConverter converter = IslStatusConverter.INSTANCE; assertEquals("active", converter.toGraphProperty(IslStatus.ACTIVE)); assertEquals("inactive", converter.toGraphProperty(IslStatus.INACTIVE)); } |
IslStatusConverter implements AttributeConverter<IslStatus, String> { @Override public IslStatus toEntityAttribute(String value) { if (value == null || value.trim().isEmpty()) { return null; } return IslStatus.valueOf(value.toUpperCase()); } @Override String toGraphProperty(IslStatus value); @Override IslStatus toEnti... | @Test public void shouldConvertToEntity() { IslStatusConverter converter = IslStatusConverter.INSTANCE; assertEquals(IslStatus.ACTIVE, converter.toEntityAttribute("ACTIVE")); assertEquals(IslStatus.ACTIVE, converter.toEntityAttribute("active")); assertEquals(IslStatus.INACTIVE, converter.toEntityAttribute("InActive"));... |
FermaPortPropertiesRepository extends FermaGenericRepository<PortProperties, PortPropertiesData, PortPropertiesFrame> implements PortPropertiesRepository { @Override public Collection<PortProperties> findAll() { return framedGraph().traverse(g -> g.V() .hasLabel(PortPropertiesFrame.FRAME_LABEL)) .toListExplicit(PortPro... | @Test public void shouldCreatePortPropertiesWithRelation() { Switch origSwitch = createTestSwitch(TEST_SWITCH_ID.getId()); PortProperties portProperties = PortProperties.builder() .switchObj(origSwitch) .discoveryEnabled(false) .build(); portPropertiesRepository.add(portProperties); Collection<PortProperties> portPrope... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.