Skip to content

Commit fc3ca65

Browse files
committed
PR fixes
1 parent 9d7c142 commit fc3ca65

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

src/main/java/com/google/firebase/remoteconfig/Condition.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,24 @@ public final class Condition {
4040
/**
4141
* Creates a new {@link Condition}.
4242
*
43-
* @param name A non-null, non-empty, and unique name of this condition.
43+
* @param name A non-null, non-empty, and unique name of this condition.
4444
* @param expression A non-null and non-empty expression of this condition.
4545
*/
4646
public Condition(@NonNull String name, @NonNull String expression) {
47-
checkArgument(!Strings.isNullOrEmpty(name), "condition name must not be null or empty");
48-
checkArgument(!Strings.isNullOrEmpty(expression),
49-
"condition expression must not be null or empty");
50-
this.name = name;
51-
this.expression = expression;
47+
this(name, expression, null);
5248
}
5349

5450
/**
5551
* Creates a new {@link Condition}.
5652
*
57-
* @param name A non-null, non-empty, and unique name of this condition.
53+
* @param name A non-null, non-empty, and unique name of this condition.
5854
* @param expression A non-null and non-empty expression of this condition.
59-
* @param tagColor A non-null tag color of this condition.
55+
* @param tagColor A tag color of this condition.
6056
*/
61-
public Condition(@NonNull String name, @NonNull String expression, @NonNull TagColor tagColor) {
57+
public Condition(@NonNull String name, @NonNull String expression, @Nullable TagColor tagColor) {
6258
checkArgument(!Strings.isNullOrEmpty(name), "condition name must not be null or empty");
6359
checkArgument(!Strings.isNullOrEmpty(expression),
6460
"condition expression must not be null or empty");
65-
checkNotNull(tagColor, "condition tag color must not be null");
6661
this.name = name;
6762
this.expression = expression;
6863
this.tagColor = tagColor;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.firebase.remoteconfig;
18+
19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertNotEquals;
21+
22+
import org.junit.Test;
23+
24+
public class ConditionTest {
25+
26+
@Test
27+
public void testEquality() {
28+
Condition conditionOne = new Condition("ios", "device.os == 'ios'", TagColor.GREEN);
29+
Condition conditionTwo = new Condition("ios", "device.os == 'ios'", TagColor.GREEN);
30+
Condition conditionThree = new Condition("android", "device.os == 'android'");
31+
Condition conditionFour = new Condition("android", "device.os == 'android'");
32+
33+
assertEquals(conditionOne, conditionTwo);
34+
assertEquals(conditionThree, conditionFour);
35+
assertNotEquals(conditionOne, conditionThree);
36+
assertNotEquals(conditionTwo, conditionFour);
37+
}
38+
}

0 commit comments

Comments
 (0)