-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse FieldsExtractorTest for processor and intellij modules (#570)
Summary: Pull Request resolved: #570 Extracted FieldsExtractorTestHelper to reuse in FieldsExtractorTest and PsiFieldsExtractorTest Reviewed By: muraziz Differential Revision: D15512731 fbshipit-source-id: bf98aa9a4bececd5e7d0277f5145453da484f4e8
- Loading branch information
1 parent
8bf9d8b
commit fa87c02
Showing
10 changed files
with
93 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
litho-processor/src/test/java/com/facebook/litho/specmodels/processor/BUCK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright (c) 2017-present, Facebook, Inc. | ||
# | ||
# This source code is licensed under the Apache 2.0 license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
load( | ||
"//tools/build_defs/oss:litho_defs.bzl", | ||
"LITHO_JUNIT_TARGET", | ||
"LITHO_VISIBILITY", | ||
"fb_java_test", | ||
"make_dep_path", | ||
) | ||
|
||
fb_java_test( | ||
name = "processor", | ||
srcs = glob( | ||
["**/*.java"], | ||
exclude = [""], | ||
include_dotfiles = False, | ||
), | ||
source = "8", | ||
target = "8", | ||
visibility = LITHO_VISIBILITY, | ||
deps = [ | ||
LITHO_JUNIT_TARGET, | ||
make_dep_path("litho-processor/src/main/java/com/facebook/litho/specmodels:specmodels"), | ||
make_dep_path("litho-processor/src/main/java/com/facebook/litho/specmodels/internal:internal"), | ||
], | ||
) |
45 changes: 45 additions & 0 deletions
45
...ssor/src/test/java/com/facebook/litho/specmodels/processor/FieldsExtractorTestHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2019-present Facebook, Inc. | ||
* | ||
* 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 com.facebook.litho.specmodels.processor; | ||
|
||
import com.facebook.litho.specmodels.internal.ImmutableList; | ||
import com.facebook.litho.specmodels.model.FieldModel; | ||
import com.squareup.javapoet.FieldSpec; | ||
import javax.lang.model.element.Modifier; | ||
import org.junit.Assert; | ||
|
||
public class FieldsExtractorTestHelper { | ||
|
||
static void fieldExtraction(ImmutableList<FieldModel> fieldModels) { | ||
Assert.assertEquals(2, fieldModels.size()); | ||
|
||
FieldSpec extractedIntField = fieldModels.get(0).field; | ||
Assert.assertEquals("intField", extractedIntField.name); | ||
Assert.assertEquals(3, extractedIntField.modifiers.size()); | ||
Assert.assertTrue(extractedIntField.hasModifier(Modifier.PRIVATE)); | ||
Assert.assertTrue(extractedIntField.hasModifier(Modifier.STATIC)); | ||
Assert.assertTrue(extractedIntField.hasModifier(Modifier.FINAL)); | ||
|
||
FieldSpec extractedFloatField = fieldModels.get(1).field; | ||
Assert.assertEquals("floatField", extractedFloatField.name); | ||
Assert.assertEquals(1, extractedFloatField.modifiers.size()); | ||
Assert.assertTrue(extractedFloatField.hasModifier(Modifier.STATIC)); | ||
} | ||
|
||
static void noFieldExtraction(ImmutableList<FieldModel> fieldModels) { | ||
Assert.assertTrue(fieldModels.isEmpty()); | ||
} | ||
} |