Skip to content

Commit

Permalink
feat: Export no-op report processor maven artifact. (#1841)
Browse files Browse the repository at this point in the history
  • Loading branch information
ple13 authored Oct 9, 2024
1 parent ede5484 commit 37486cb
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Report Post Processing Library

## Maven Artifact

This library is available as a Maven artifact from a GitHub Packages Maven
registry. See
[Installing a package](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry#installing-a-package)
from the GitHub documentation. The primary artifact is
`org.wfanet.measurement.eventdataprovider:postprocessing-v2alpha`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@rules_jvm_external//:defs.bzl", "maven_export")
load("@wfa_common_jvm//build/maven:defs.bzl", "artifact_version")
load("@wfa_rules_kotlin_jvm//kotlin:defs.bzl", "kt_jvm_library")

package(default_visibility = ["//visibility:public"])

MAVEN_COORDINATES = "org.wfanet.measurement.reporting:postprocessing-v2alpha:" + artifact_version()

kt_jvm_library(
name = "postprocessing",
srcs = glob(["*.kt"]),
tags = ["maven_coordinates=" + MAVEN_COORDINATES],
)

maven_export(
name = "postprocessing_maven",
lib_name = "postprocessing",
maven_coordinates = MAVEN_COORDINATES,
tags = ["no-javadocs"],
visibility = ["//visibility:private"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2024 The Cross-Media Measurement Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.reporting.postprocessing.v2alpha

/**
* A no-op implementation of [ReportProcessor] that takes a serialized [Report] in JSON format and
* returns the same [Report] without any modifications.
*/
class NoOpReportProcessor : ReportProcessor {
/** Returns the input [report] without any modifications. */
override fun processReportJson(report: String): String {
return report
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2024 The Cross-Media Measurement Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.reporting.postprocessing.v2alpha

/** Corrects the inconsistent measurements in a serialized [Report]. */
interface ReportProcessor {
/**
* Processes a serialized [Report] and outputs a consistent one.
*
* @param report The serialized [Report] in JSON format.
* @return The corrected serialized [Report] in JSON format.
*/
fun processReportJson(report: String): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@wfa_rules_kotlin_jvm//kotlin:defs.bzl", "kt_jvm_test")

package(default_testonly = True)

kt_jvm_test(
name = "no_op_report_processor_test",
srcs = ["NoOpReportProcessorTest.kt"],
test_class = "org.wfanet.measurement.reporting.postprocessing.v2alpha.NoOpReportProcessorTest",
deps = [
"//src/main/kotlin/org/wfanet/measurement/reporting/postprocessing/v2alpha:postprocessing",
"@wfa_common_jvm//imports/java/com/google/common/truth",
"@wfa_common_jvm//imports/java/com/google/common/truth/extensions/proto",
"@wfa_common_jvm//imports/java/org/junit",
"@wfa_common_jvm//imports/kotlin/kotlin/test",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2024 The Cross-Media Measurement Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.wfanet.measurement.reporting.postprocessing.v2alpha

import com.google.common.truth.Truth.assertThat
import com.google.common.truth.extensions.proto.ProtoTruth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(JUnit4::class)
class NoOpReportProcessorTest {
@Test
fun `The default report processor successfully processes a report`() {
val reportProcessor = NoOpReportProcessor()
val processedReport = reportProcessor.processReportJson(SAMPLE_REPORT)
assertThat(processedReport).isEqualTo(SAMPLE_REPORT)
}

companion object {
private val SAMPLE_REPORT =
"""
{
"name": "Sample report",
"reportingMetricEntries": [],
"state": "STATE_UNSPECIFIED",
"metricCalculationResults": [],
"reportSchedule": "",
"tags": {},
"reportingInterval": {}
}
"""
}
}

0 comments on commit 37486cb

Please sign in to comment.