Skip to content

Commit d63dba2

Browse files
most tests pass
1 parent 6bc88df commit d63dba2

File tree

11 files changed

+27
-22
lines changed

11 files changed

+27
-22
lines changed

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ allprojects {
4343

4444
subprojects {
4545
apply plugin: 'com.jfrog.bintray'
46-
apply plugin: 'findbugs'
46+
//apply plugin: 'findbugs'
4747
apply plugin: 'jacoco'
4848
apply plugin: 'java'
4949
apply plugin: 'maven-publish'
@@ -72,12 +72,12 @@ subprojects {
7272
archives javadocJar
7373
}
7474

75-
tasks.withType(FindBugs) {
76-
reports {
77-
xml.enabled = false
78-
html.enabled = true
79-
}
80-
}
75+
// tasks.withType(FindBugs) {
76+
// reports {
77+
// xml.enabled = false
78+
// html.enabled = true
79+
// }
80+
// }
8181

8282
test {
8383
useJUnit {

core-api/src/main/kotlin/com/optimizely/ab/bucketing/Bucketer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ open class Bucketer(private val projectConfig: ProjectConfig) {
151151
@VisibleForTesting
152152
internal open fun generateBucketValue(hashCode: Int): Int {
153153
// map the hashCode into the range [0, BucketAlgorithm.MAX_TRAFFIC_VALUE)
154-
val ratio = (hashCode and 0xFFFFFFFFL as Int).toDouble() / Math.pow(2.0, 32.0)
154+
val ratio = (hashCode.toLong() and 0xFFFFFFFFL as Long).toDouble() / Math.pow(2.0, 32.0)
155155
return Math.floor(MAX_TRAFFIC_VALUE * ratio).toInt()
156156
}
157157

core-api/src/main/kotlin/com/optimizely/ab/config/ProjectConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ProjectConfig// v4 constructor
101101
* whitelisting forcedVariations data structure in the Experiments class).
102102
*/
103103
@Transient
104-
val forcedVariationMapping = ConcurrentHashMap<String, ConcurrentHashMap<String, String>>()
104+
val forcedVariationMapping:ConcurrentHashMap<String, ConcurrentHashMap<String, String>> = ConcurrentHashMap<String, ConcurrentHashMap<String, String>>()
105105

106106
// v3 constructor
107107
@JvmOverloads constructor(accountId: String, projectId: String, version: String, revision: String, groups: List<Group>,
@@ -334,7 +334,7 @@ class ProjectConfig// v4 constructor
334334

335335
val experimentToVariation: ConcurrentHashMap<String, String>
336336
if (!forcedVariationMapping.containsKey(userId)) {
337-
(forcedVariationMapping as java.util.Map<String, ConcurrentHashMap<String, String>>).putIfAbsent(userId, ConcurrentHashMap())
337+
(forcedVariationMapping as MutableMap<String, ConcurrentHashMap<*,*>>).putIfAbsent(userId, ConcurrentHashMap<Any, Any>())
338338
}
339339
experimentToVariation = forcedVariationMapping[userId]!!
340340

core-api/src/main/kotlin/com/optimizely/ab/config/ProjectConfigUtils.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ object ProjectConfigUtils {
6060
val variation = experiment.variations[0]
6161
if (variation.liveVariableUsageInstances != null) {
6262
for (usageInstance in variation.liveVariableUsageInstances) {
63-
var experimentsUsingVariable: MutableList<Experiment>? = ArrayList(variableIdToExperiments[usageInstance.id])
63+
64+
var experimentsUsingVariable: MutableList<Experiment>? = null;
65+
66+
if (variableIdToExperiments[usageInstance.id] != null) {
67+
experimentsUsingVariable = ArrayList(variableIdToExperiments[usageInstance.id])
68+
}
6469
if (experimentsUsingVariable == null) {
6570
experimentsUsingVariable = ArrayList()
6671
}

core-api/src/main/kotlin/com/optimizely/ab/notification/NotificationCenter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class NotificationCenter {
6464
* @param activateNotificationListenerInterface
6565
* @return greater than zero if added.
6666
*/
67-
fun addActivateNotificationListener(activateNotificationListenerInterface: (Any, Any, Any, Any, Any) -> Unit): Int {
67+
fun addActivateNotificationListener(activateNotificationListenerInterface: (Experiment, String, Map<String,String>, Variation, LogEvent) -> Unit): Int {
6868
return if (activateNotificationListenerInterface is ActivateNotificationListener) {
6969
addNotificationListener(NotificationType.Activate, activateNotificationListenerInterface as NotificationListener)
7070
} else {
@@ -81,7 +81,7 @@ class NotificationCenter {
8181
* @param trackNotificationListenerInterface
8282
* @return greater than zero if added.
8383
*/
84-
fun addTrackNotificationListener(trackNotificationListenerInterface: (Any, Any, Any, Any, Any) -> Unit): Int {
84+
fun addTrackNotificationListener(trackNotificationListenerInterface: (String, String, Map<String, String>, Map<String,*>,LogEvent) -> Unit): Int {
8585
return if (trackNotificationListenerInterface is TrackNotificationListener) {
8686
addNotificationListener(NotificationType.Activate, trackNotificationListenerInterface as NotificationListener)
8787
} else {

core-api/src/test/kotlin/com/optimizely/ab/OptimizelyBuilderTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ import org.mockito.Mockito.mock
5353
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
5454
class OptimizelyBuilderTest {
5555

56-
@Rule
57-
var thrown = ExpectedException.none()
56+
@get:Rule
57+
public var thrown = ExpectedException.none()
5858

59-
@Rule
60-
var rule = MockitoJUnit.rule()
59+
@get:Rule
60+
public var rule = MockitoJUnit.rule()
6161

6262
@Mock private val mockEventHandler: EventHandler? = null
6363

core-api/src/test/kotlin/com/optimizely/ab/config/ProjectConfigTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ProjectConfigTest {
5151

5252
private var projectConfig: ProjectConfig? = null
5353

54-
@Rule
54+
@get:Rule
5555
var logbackVerifier = LogbackVerifier()
5656

5757
@Before

core-api/src/test/kotlin/com/optimizely/ab/config/parser/GsonConfigParserTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import com.optimizely.ab.config.ProjectConfigTestUtils.verifyProjectConfig
3535
*/
3636
class GsonConfigParserTest {
3737

38-
@Rule
38+
@get:Rule
3939
var thrown = ExpectedException.none()
4040

4141
@Test

core-api/src/test/kotlin/com/optimizely/ab/config/parser/JacksonConfigParserTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import com.optimizely.ab.config.ProjectConfigTestUtils.verifyProjectConfig
3535
*/
3636
class JacksonConfigParserTest {
3737

38-
@Rule
38+
@get:Rule
3939
var thrown = ExpectedException.none()
4040

4141
@Test

core-api/src/test/kotlin/com/optimizely/ab/config/parser/JsonConfigParserTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import com.optimizely.ab.config.ProjectConfigTestUtils.verifyProjectConfig
3636
*/
3737
class JsonConfigParserTest {
3838

39-
@Rule
39+
@get:Rule
4040
var thrown = ExpectedException.none()
4141

4242
@Test

0 commit comments

Comments
 (0)