From 7b89f1862cd26a970e644d18977a24734649e51e Mon Sep 17 00:00:00 2001 From: Stefan Bischof Date: Tue, 29 Mar 2022 11:51:01 +0200 Subject: [PATCH] [assertj,cm] Assertions and Conditions on CofigurationEvent Signed-off-by: Stefan Bischof --- org.osgi.test.assertj.cm/.project | 23 + .../org.eclipse.core.resources.prefs | 4 + .../.settings/org.eclipse.core.runtime.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 517 ++++++++++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 135 +++++ .../.settings/org.eclipse.m2e.core.prefs | 4 + org.osgi.test.assertj.cm/README.md | 3 + org.osgi.test.assertj.cm/logback.xml | 35 ++ org.osgi.test.assertj.cm/pom.xml | 89 +++ .../cm/ConfigurationBddAssertions.java | 59 ++ .../cm/ConfigurationSoftAssertions.java | 52 ++ .../AbstractConfigurationAssert.java | 232 ++++++++ .../cm/configuration/ConfigurationAssert.java | 53 ++ .../ConfigurationConditions.java | 115 ++++ .../cm/configuration/package-info.java | 15 + .../AbstractConfigurationEventAssert.java | 158 ++++++ .../ConfigurationEventAssert.java | 55 ++ .../ConfigurationEventConditions.java | 160 ++++++ .../ConfigurationEventType.java | 47 ++ .../cm/configurationevent/package-info.java | 21 + .../osgi/test/assertj/cm/package-info.java | 21 + .../cm/test/ConfigurationEventTypeTest.java | 41 ++ .../ConfigurationEventAssertTest.java | 143 +++++ .../ConfigurationEventAssertTest.java | 152 +++++ .../ConfigurationEventConditionsTest.java | 185 +++++++ .../cm/test/util/AbstractAssertTest.java | 61 +++ .../test/assertj/cm/test/util/AssertTest.java | 196 +++++++ .../assertj/cm/test/util/ConditionAssert.java | 75 +++ .../assertj/cm/test/util/ConditionMethod.java | 39 ++ org.osgi.test.assertj.cm/test.bndrun | 46 ++ .../test/testutil/ConditionAssert.java | 75 +++ .../test/testutil/ConditionMethod.java | 39 ++ org.osgi.test.bom/pom.xml | 6 + org.osgi.test.junit5.cm/test.bndrun | 1 + pom.xml | 1 + 35 files changed, 2860 insertions(+) create mode 100644 org.osgi.test.assertj.cm/.project create mode 100644 org.osgi.test.assertj.cm/.settings/org.eclipse.core.resources.prefs create mode 100644 org.osgi.test.assertj.cm/.settings/org.eclipse.core.runtime.prefs create mode 100644 org.osgi.test.assertj.cm/.settings/org.eclipse.jdt.core.prefs create mode 100644 org.osgi.test.assertj.cm/.settings/org.eclipse.jdt.ui.prefs create mode 100644 org.osgi.test.assertj.cm/.settings/org.eclipse.m2e.core.prefs create mode 100644 org.osgi.test.assertj.cm/README.md create mode 100644 org.osgi.test.assertj.cm/logback.xml create mode 100644 org.osgi.test.assertj.cm/pom.xml create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/ConfigurationBddAssertions.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/ConfigurationSoftAssertions.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/AbstractConfigurationAssert.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/ConfigurationAssert.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/ConfigurationConditions.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/package-info.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/AbstractConfigurationEventAssert.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventAssert.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventConditions.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventType.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/package-info.java create mode 100644 org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/package-info.java create mode 100644 org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/ConfigurationEventTypeTest.java create mode 100644 org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configuration/ConfigurationEventAssertTest.java create mode 100644 org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configurationevent/ConfigurationEventAssertTest.java create mode 100644 org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configurationevent/ConfigurationEventConditionsTest.java create mode 100644 org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/AbstractAssertTest.java create mode 100644 org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/AssertTest.java create mode 100644 org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/ConditionAssert.java create mode 100644 org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/ConditionMethod.java create mode 100644 org.osgi.test.assertj.cm/test.bndrun create mode 100644 org.osgi.test.assertj.framework/src/test/java/org/osgi/test/assertj/test/testutil/ConditionAssert.java create mode 100644 org.osgi.test.assertj.framework/src/test/java/org/osgi/test/assertj/test/testutil/ConditionMethod.java diff --git a/org.osgi.test.assertj.cm/.project b/org.osgi.test.assertj.cm/.project new file mode 100644 index 00000000..5983e48a --- /dev/null +++ b/org.osgi.test.assertj.cm/.project @@ -0,0 +1,23 @@ + + + org.osgi.test.assertj.cm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/org.osgi.test.assertj.cm/.settings/org.eclipse.core.resources.prefs b/org.osgi.test.assertj.cm/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..f9fe3459 --- /dev/null +++ b/org.osgi.test.assertj.cm/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/org.osgi.test.assertj.cm/.settings/org.eclipse.core.runtime.prefs b/org.osgi.test.assertj.cm/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 00000000..5a0ad22d --- /dev/null +++ b/org.osgi.test.assertj.cm/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/org.osgi.test.assertj.cm/.settings/org.eclipse.jdt.core.prefs b/org.osgi.test.assertj.cm/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..88a52ef8 --- /dev/null +++ b/org.osgi.test.assertj.cm/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,517 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 +org.eclipse.jdt.core.compiler.problem.APILeak=warning +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled +org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL +org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME +org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=true +org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false +org.eclipse.jdt.core.formatter.align_with_spaces=false +org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=17 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=81 +org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 +org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=false +org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.indent_tag_description=false +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=1 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false +org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_if_empty +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true +org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true +org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true +org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/org.osgi.test.assertj.cm/.settings/org.eclipse.jdt.ui.prefs b/org.osgi.test.assertj.cm/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..6009701c --- /dev/null +++ b/org.osgi.test.assertj.cm/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,135 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_functional_interfaces=true +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=false +cleanup.format_source_code=false +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=false +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_redundant_modifiers=true +cleanup.remove_redundant_semicolons=true +cleanup.remove_redundant_type_arguments=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=true +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_blocks=false +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=false +cleanup.use_this_for_non_static_field_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_type_arguments=false +cleanup_profile=_bnd +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_bnd +formatter_settings_version=16 +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; +org.eclipse.jdt.ui.javadoc=false +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=99 +org.eclipse.jdt.ui.text.custom_code_templates= +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=true +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_with_declaring_class=true +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_redundant_modifiers=true +sp_cleanup.remove_redundant_semicolons=true +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=true +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +sp_cleanup.use_type_arguments=false diff --git a/org.osgi.test.assertj.cm/.settings/org.eclipse.m2e.core.prefs b/org.osgi.test.assertj.cm/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..f897a7f1 --- /dev/null +++ b/org.osgi.test.assertj.cm/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/org.osgi.test.assertj.cm/README.md b/org.osgi.test.assertj.cm/README.md new file mode 100644 index 00000000..d72b4403 --- /dev/null +++ b/org.osgi.test.assertj.cm/README.md @@ -0,0 +1,3 @@ +# org.osgi.test.assertj.cm + +This artifact provides support classes for OSGi testing with [AssertJ](https://github.com/joel-costigliola/assertj-core) ConfigurationAdmin diff --git a/org.osgi.test.assertj.cm/logback.xml b/org.osgi.test.assertj.cm/logback.xml new file mode 100644 index 00000000..1bfb558f --- /dev/null +++ b/org.osgi.test.assertj.cm/logback.xml @@ -0,0 +1,35 @@ + + + + + true + + + + + %-4relative [%.15thread] %-5level %logger{36}:%line - %msg%n + + + + + + + + + diff --git a/org.osgi.test.assertj.cm/pom.xml b/org.osgi.test.assertj.cm/pom.xml new file mode 100644 index 00000000..626a0b11 --- /dev/null +++ b/org.osgi.test.assertj.cm/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + + org.osgi + org.osgi.test.parent + ${revision} + ../pom.xml + + + org.osgi.test.assertj.cm + OSGi Testing AssertJ Support for Configuration Admin + ${project.groupId}:${project.artifactId} + https://www.osgi.org + + https://github.com/osgi/osgi-test + scm:git:https://github.com/osgi/osgi-test.git + scm:git:git@github.com:osgi/osgi-test.git + + + + + org.osgi + osgi.annotation + + + org.osgi + org.osgi.test.assertj.framework + ${revision} + + + org.osgi + org.osgi.test.assertj.framework + ${revision} + tests + test + + + org.osgi + org.osgi.service.cm + + + org.osgi + org.osgi.test.common + ${revision} + + + org.assertj + assertj-core + compile + + + org.osgi + org.osgi.framework + + + org.mockito + mockito-core + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.jupiter + junit-jupiter-params + + + diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/ConfigurationBddAssertions.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/ConfigurationBddAssertions.java new file mode 100644 index 00000000..0e76aa21 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/ConfigurationBddAssertions.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm; + +import org.osgi.test.assertj.cm.configuration.ConfigurationAssert; +import org.osgi.test.assertj.cm.configurationevent.ConfigurationEventAssert; + +/** + * Entry point for BDD assertions of different data types. + */ +public class ConfigurationBddAssertions { + + /** + * Creates a new instance of + * {@link org.osgi.test.assertj.cm.configuration.ConfigurationAssert}. + * + * @param actual the actual value. + * @return the created assertion object. + */ + + public static ConfigurationAssert then(org.osgi.service.cm.Configuration actual) { + return new ConfigurationAssert(actual); + } + + /** + * Creates a new instance of + * {@link org.osgi.test.assertj.cm.configurationevent.ConfigurationEventAssert}. + * + * @param actual the actual value. + * @return the created assertion object. + */ + + public static ConfigurationEventAssert then(org.osgi.service.cm.ConfigurationEvent actual) { + return new ConfigurationEventAssert(actual); + } + + /** + * Creates a new {@link ConfigurationBddAssertions}. + */ + protected ConfigurationBddAssertions() { + // empty + } +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/ConfigurationSoftAssertions.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/ConfigurationSoftAssertions.java new file mode 100644 index 00000000..f769ecab --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/ConfigurationSoftAssertions.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm; + +import org.osgi.test.assertj.cm.configuration.ConfigurationAssert; +import org.osgi.test.assertj.cm.configurationevent.ConfigurationEventAssert; + +/** + * Entry point for soft assertions of different data types. + */ +public class ConfigurationSoftAssertions extends org.assertj.core.api.SoftAssertions { + + /** + * Creates a new "soft" instance of + * {@link org.osgi.test.assertj.cm.configuration.ConfigurationAssert}. + * + * @param actual the actual value. + * @return the created "soft" assertion object. + */ + + public ConfigurationAssert assertThat(org.osgi.service.cm.Configuration actual) { + return proxy(ConfigurationAssert.class, org.osgi.service.cm.Configuration.class, actual); + } + + /** + * Creates a new "soft" instance of + * {@link org.osgi.test.assertj.cm.configurationevent.ConfigurationEventAssert}. + * + * @param actual the actual value. + * @return the created "soft" assertion object. + */ + + public ConfigurationEventAssert assertThat(org.osgi.service.cm.ConfigurationEvent actual) { + return proxy(ConfigurationEventAssert.class, org.osgi.service.cm.ConfigurationEvent.class, actual); + } +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/AbstractConfigurationAssert.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/AbstractConfigurationAssert.java new file mode 100644 index 00000000..b88bcc65 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/AbstractConfigurationAssert.java @@ -0,0 +1,232 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.configuration; + +import java.util.Objects; + +import org.assertj.core.api.AbstractObjectAssert; +import org.osgi.service.cm.Configuration; +import org.osgi.test.assertj.dictionary.DictionaryAssert; + +/** + * Abstract base class for {@link Configuration} specific assertions + */ +public abstract class AbstractConfigurationAssert, A extends Configuration> + extends AbstractObjectAssert { + + /** + * Creates a new {@link AbstractConfigurationAssert} to make + * assertions on actual Configuration. + * + * @param actual the Configuration we want to make assertions on. + */ + protected AbstractConfigurationAssert(A actual, Class selfType) { + super(actual, selfType); + } + + + /** + * Verifies that the actual Configuration's bundleLocation is equal to the + * given one. + * + * @param bundleLocation the given bundleLocation to compare the actual + * Configuration's bundleLocation to. + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's bundleLocation is + * not equal to the given one. + */ + public S hasBundleLocation(String bundleLocation) { + // check that actual Configuration we want to make assertions on is not + // null. + isNotNull(); + + // overrides the default error message with a more explicit one + String assertjErrorMessage = "\nExpecting bundleLocation of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; + + // null safe check + String actualBundleLocation = actual.getBundleLocation(); + if (!Objects.equals(actualBundleLocation, bundleLocation)) { + failWithMessage(assertjErrorMessage, actual, bundleLocation, actualBundleLocation); + } + + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual Configuration's changeCount is equal to the + * given one. + * + * @param changeCount the given changeCount to compare the actual + * Configuration's changeCount to. + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's changeCount is not + * equal to the given one. + */ + public S hasChangeCount(long changeCount) { + // check that actual Configuration we want to make assertions on is not + // null. + isNotNull(); + + // overrides the default error message with a more explicit one + String assertjErrorMessage = "\nExpecting changeCount of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; + + // check + long actualChangeCount = actual.getChangeCount(); + if (actualChangeCount != changeCount) { + failWithMessage(assertjErrorMessage, actual, changeCount, actualChangeCount); + } + + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual Configuration's changeCount is greater then the + * given one. + * + * @param changeCount the given changeCount to compare the actual + * Configuration's changeCount to. + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's changeCount is not + * greaterThen the given one. + */ + public S hasChangeCountGreater(long changeCount) { + // check that actual Configuration we want to make assertions on is not + // null. + isNotNull(); + + // overrides the default error message with a more explicit one + String assertjErrorMessage = "\nExpecting changeCount of:\n <%s>\nto be greater then:\n <%s>\nbut was:\n <%s>"; + + // check + long actualChangeCount = actual.getChangeCount(); + if (actualChangeCount <= changeCount) { + failWithMessage(assertjErrorMessage, actual, changeCount, actualChangeCount); + } + + // return the current assertion for method chaining + return myself; + } + + + /** + * Delegates to a DictionaryAssert using the properties of the + * Configuration. + * + * @throws AssertionError - if the actual Configuration's properties is + * null. + * @return the dictionary assert + */ + public DictionaryAssert hasProperiesThat() { + isNotNull(); + return DictionaryAssert.assertThat(actual.getProperties()) + .as(actual + ".properties"); + } + + /** + * Verifies that the actual Configuration's factoryPid is equal to the given + * one. + * + * @param factoryPid the given factoryPid to compare the actual + * Configuration's factoryPid to. + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's factoryPid is not + * equal to the given one. + */ + public S hasFactoryPidEqualsTo(String factoryPid) { + + isNotNull().has(ConfigurationConditions.factoryPid(factoryPid)); + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual Configuration's factoryPid is not null. + * + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's factoryPid is + * null. + */ + public S hasFactoryPid() { + + isNotNull().has(ConfigurationConditions.factoryPidNotNull()); + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual Configuration's factoryPid is null. + * + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's factoryPid is not + * null. + */ + public S hasNoFactoryPid() { + + isNotNull().has(ConfigurationConditions.factoryPidNull()); + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual Configuration's pid is not null. + * + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's pid is null + */ + public S hasPid() { + + isNotNull().has(ConfigurationConditions.pidNotNull()); + + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual Configuration's pid is null. + * + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's pid is not null. + */ + public S hasNoPid() { + + isNotNull().has(ConfigurationConditions.pidNull()); + + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual Configuration's pid is equal to the given one. + * + * @param pid the given pid to compare the actual Configuration's pid to. + * @return this assertion object. + * @throws AssertionError - if the actual Configuration's pid is not equal + * to the given one. + */ + public S hasPidEqualsTo(String pid) { + + isNotNull().has(ConfigurationConditions.pid(pid)); + + // return the current assertion for method chaining + return myself; + } + +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/ConfigurationAssert.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/ConfigurationAssert.java new file mode 100644 index 00000000..ba162714 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/ConfigurationAssert.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.configuration; + +import org.osgi.service.cm.Configuration; + +/** + * {@link Configuration} specific assertions Although this class is not final to + * allow Soft assertions proxy, if you wish to extend it, extend + * {@link AbstractConfigurationAssert} instead. + */ +public class ConfigurationAssert extends AbstractConfigurationAssert { + + /** + * Creates a new {@link ConfigurationAssert} to make assertions + * on actual Configuration. + * + * @param actual the Configuration we want to make assertions on. + */ + public ConfigurationAssert(Configuration actual) { + super(actual, ConfigurationAssert.class); + } + + /** + * An entry point for ConfigurationAssert to follow AssertJ standard + * assertThat() statements.
+ * With a static import, one can write directly: + * assertThat(myConfiguration) and get specific assertion with + * code completion. + * + * @param actual the Configuration we want to make assertions on. + * @return a new {@link ConfigurationAssert} + */ + public static ConfigurationAssert assertThat(Configuration actual) { + return new ConfigurationAssert(actual); + } +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/ConfigurationConditions.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/ConfigurationConditions.java new file mode 100644 index 00000000..bc5f4b8f --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/ConfigurationConditions.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.configuration; + +import java.util.Objects; + +import org.assertj.core.api.Condition; +import org.assertj.core.condition.VerboseCondition; +import org.osgi.service.cm.Configuration; + +/** + * A Utility-Class thats Provides public static methods to create + * {@link Condition}s for an Configuration} + */ +public class ConfigurationConditions { + + private ConfigurationConditions() {} + + /** + * Creates a {@link Condition} to be met by an Configuration. Checking + * if the pid of the Configuration is not null. + * + * @return the condition + */ + public static Condition pidNotNull() { + + return new Condition(e -> Objects.nonNull(e.getPid()), "pid is not "); + + } + + /** + * Creates a {@link Condition} to be met by an Configuration. Checking + * if the pid of the Configuration is null. + * + * @return the condition + */ + public static Condition pidNull() { + + return VerboseCondition.verboseCondition((Configuration e) -> e.getPid() == null, "pid is ", // + e -> " was <" + e.getPid() + ">"); + + } + + /** + * Creates a {@link Condition} to be met by an Configuration. Checking + * if the factoryPid of the Configuration is not null. + * + * @return the condition + */ + public static Condition factoryPidNotNull() { + + return new Condition(e -> Objects.nonNull(e.getFactoryPid()), "factoryPid is not "); + + } + + /** + * Creates a {@link Condition} to be met by an Configuration. Checking + * if the factoryPid of the Configuration is null. + * + * @return the condition + */ + public static Condition factoryPidNull() { + + return VerboseCondition.verboseCondition((Configuration e) -> e.getFactoryPid() == null, "factoryPid is ", // + e -> " was <" + e.getFactoryPid() + ">"); + + } + + /** + * Creates a {@link Condition} to be met by an Configuration. Checking + * if a given pid matches the pid of the Configuration. + * + * @param pid the pid + * @return the condition + */ + public static Condition pid(final String pid) { + + return VerboseCondition.verboseCondition((Configuration e) -> Objects.equals(e.getPid(), pid), + "pid equals <" + pid + ">", // + e -> " was <" + e.getPid() + ">"); + + } + + /** + * Creates a {@link Condition} to be met by an Configuration. Checking + * if a given factoryPid matches the factoryPid of the Configuration. + * + * @param factoryPid the factory pid + * @return the condition + */ + public static Condition factoryPid(final String factoryPid) { + + return VerboseCondition.verboseCondition((Configuration e) -> Objects.equals(e.getFactoryPid(), factoryPid), + "factoryPid equals <" + factoryPid + ">", // + e -> " was <" + e.getFactoryPid() + ">"); + + } + +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/package-info.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/package-info.java new file mode 100644 index 00000000..cbfc02e6 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configuration/package-info.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation 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. + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +@org.osgi.annotation.bundle.Export +@org.osgi.annotation.versioning.Version("1.0.0") +package org.osgi.test.assertj.cm.configuration; diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/AbstractConfigurationEventAssert.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/AbstractConfigurationEventAssert.java new file mode 100644 index 00000000..3051b6f6 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/AbstractConfigurationEventAssert.java @@ -0,0 +1,158 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.configurationevent; + +import static org.assertj.core.api.Assertions.not; + +import org.assertj.core.api.AbstractObjectAssert; +import org.osgi.service.cm.ConfigurationEvent; +import org.osgi.test.assertj.servicereference.ServiceReferenceAssert; + +/** + * Abstract base class for {@link ConfigurationEvent} specific assertions + */ +public abstract class AbstractConfigurationEventAssert, A extends ConfigurationEvent> + extends AbstractObjectAssert { + + /** + * Creates a new {@link AbstractConfigurationEventAssert} to + * make assertions on actual ConfigurationEvent. + * + * @param actual the ConfigurationEvent we want to make assertions on. + */ + protected AbstractConfigurationEventAssert(A actual, Class selfType) { + super(actual, selfType); + } + + /** + * Verifies that the actual ConfigurationEvent's factoryPid is equal to the + * given one. + * + * @param factoryPid the given factoryPid to compare the actual + * ConfigurationEvent's factoryPid to. + * @return this assertion object. + * @throws AssertionError - if the actual ConfigurationEvent's factoryPid is + * not equal to the given one. + */ + public S hasFactoryPidEqualsTo(String factoryPid) { + + isNotNull().has(ConfigurationEventConditions.factoryPid(factoryPid)); + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual ConfigurationEvent's factoryPid is not null. + * + * @return this assertion object. + * @throws AssertionError - if the actual ConfigurationEvent's factoryPid is + * null. + */ + public S hasFactoryPid() { + + isNotNull().has(not(ConfigurationEventConditions.factoryPidNull())); + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual ConfigurationEvent's factoryPid is null. + * + * @return this assertion object. + * @throws AssertionError - if the actual ConfigurationEvent's factoryPid is + * not null. + */ + public S hasNoFactoryPid() { + + isNotNull().has(ConfigurationEventConditions.factoryPidNull()); + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual ConfigurationEvent's pid is not null. + * + * @return this assertion object. + * @throws AssertionError - if the actual ConfigurationEvent's pid is null + */ + public S hasPid() { + + isNotNull().has(not(ConfigurationEventConditions.pidNull())); + + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual ConfigurationEvent's pid is null. + * + * @return this assertion object. + * @throws AssertionError - if the actual ConfigurationEvent's pid is not + * null. + */ + public S hasNoPid() { + + isNotNull().has(ConfigurationEventConditions.pidNull()); + + // return the current assertion for method chaining + return myself; + } + + /** + * Verifies that the actual ConfigurationEvent's pid is equal to the given + * one. + * + * @param pid the given pid to compare the actual ConfigurationEvent's pid + * to. + * @return this assertion object. + * @throws AssertionError - if the actual ConfigurationEvent's pid is not + * equal to the given one. + */ + public S hasPidEqualsTo(String pid) { + + isNotNull().has(ConfigurationEventConditions.pid(pid)); + + // return the current assertion for method chaining + return myself; + } + + public ServiceReferenceAssert hasReferenceThat() { + return ServiceReferenceAssert.assertThat(actual.getReference()) + .as(actual + ".reference"); + } + + /** + * Verifies that the actual ConfigurationEvent's type matches to the given + * type. + * + * @param type the given type to compare the actual ConfigurationEvent's + * type to. + * @return this assertion object. + * @throws AssertionError - if the actual ConfigurationEvent's type is not + * matching to the given one. + */ + public S hasTypeEqualTo(int type) { + + isNotNull().has(ConfigurationEventConditions.type(type)); + + // return the current assertion for method chaining + return myself; + } + +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventAssert.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventAssert.java new file mode 100644 index 00000000..c4990de1 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventAssert.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.configurationevent; + +import org.osgi.service.cm.ConfigurationEvent; + +/** + * {@link ConfigurationEvent} specific assertions. Although this class is not + * final to allow Soft assertions proxy, if you wish to extend it, extend + * {@link AbstractConfigurationEventAssert} instead. + */ +public class ConfigurationEventAssert + extends AbstractConfigurationEventAssert { + + /** + * Creates a new {@link ConfigurationEventAssert} to make + * assertions on actual ConfigurationEvent. + * + * @param actual the ConfigurationEvent we want to make assertions on. + */ + public ConfigurationEventAssert(ConfigurationEvent actual) { + super(actual, ConfigurationEventAssert.class); + } + + /** + * An entry point for ConfigurationEventAssert to follow AssertJ standard + * assertThat() statements.
+ * With a static import, one can write directly: + * assertThat(myConfigurationEvent) and get specific assertion + * with code completion. + * + * @param actual the ConfigurationEvent we want to make assertions on. + * @return a new {@link ConfigurationEventAssert} + */ + + public static ConfigurationEventAssert assertThat(ConfigurationEvent actual) { + return new ConfigurationEventAssert(actual); + } +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventConditions.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventConditions.java new file mode 100644 index 00000000..df943f45 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventConditions.java @@ -0,0 +1,160 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.configurationevent; + +import static org.assertj.core.api.Assertions.allOf; +import static org.assertj.core.api.Assertions.anyOf; +import static org.assertj.core.api.Assertions.not; + +import java.util.Objects; + +import org.assertj.core.api.Condition; +import org.assertj.core.condition.VerboseCondition; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationEvent; + +/** + * A Utility-Class thats Provides public static methods to create + * {@link Condition}s for an ConfigurationEvent} + */ +public final class ConfigurationEventConditions { + + private ConfigurationEventConditions() {} + + /** + * Creates a {@link Condition} to be met by an ConfigurationEvent. + * Checking if a given {@link Configuration} matches the pid OR + * factoryPid of the Event. + * + * @param configuration the configuration + * @return the condition + */ + public static Condition matches(Configuration configuration) { + return anyOf(allOf(not(pidNull()), pid(configuration.getPid())), + allOf(not(factoryPidNull()), factoryPid(configuration.getFactoryPid()))); + + } + + /** + * Creates a {@link Condition} to be met by an ConfigurationEvent. + * Checking if a given type- matches the type of the Event. + * + * @param eventType the type that would be checked against the type of the + * ConfigurationEvent} + * + * @return the condition + */ + public static Condition type(final int eventType) { + + return VerboseCondition.verboseCondition((ConfigurationEvent e) -> e.getType() == eventType, + "type is <" + ConfigurationEventType.toString(eventType) + ">", // + e -> " was <" + ConfigurationEventType.toString(e.getType()) + ">"); + + } + + /** + * Creates a {@link Condition} to be met by an ConfigurationEvent. + * Checking if the pid of the Event is null. + * + * @return the condition + */ + public static Condition pidNull() { + + return VerboseCondition.verboseCondition((ConfigurationEvent e) -> e.getPid() == null, "pid is ", // + e -> " was <" + e.getPid() + ">"); + + } + + /** + * Creates a {@link Condition} to be met by an ConfigurationEvent. + * Checking if the factoryPid of the Event is null. + * + * @return the condition + */ + public static Condition factoryPidNull() { + + return VerboseCondition.verboseCondition((ConfigurationEvent e) -> e.getFactoryPid() == null, + "factoryPid is ", // + e -> " was <" + e.getFactoryPid() + ">"); + + } + + /** + * Creates a {@link Condition} to be met by an ConfigurationEvent. + * Checking if a given pid matches the pid of the Event. + * + * @param pid the pid + * @return the condition + */ + public static Condition pid(final String pid) { + + return VerboseCondition.verboseCondition((ConfigurationEvent e) -> Objects.equals(e.getPid(), pid), + "pid equals <" + pid + ">", // + e -> " was <" + e.getPid() + ">"); + + } + + /** + * Creates a {@link Condition} to be met by an ConfigurationEvent. + * Checking if a given factoryPid matches the factoryPid of the + * Event. + * + * @param factoryPid the factory pid + * @return the condition + */ + public static Condition factoryPid(final String factoryPid) { + + return VerboseCondition.verboseCondition( + (ConfigurationEvent e) -> Objects.equals(e.getFactoryPid(), factoryPid), + "factoryPid equals <" + factoryPid + ">", // + e -> " was <" + e.getFactoryPid() + ">"); + + } + /** + * Creates a {@link Condition} to be met by an ConfigurationEvent. + * Checking if a given pid matches the pid and a given type + * matches the type of the Event. + * + * @param eventType the type that would be checked against the type of the + * ConfigurationEvent} + * + * @param pid the pid + * @return the condition + */ + public static Condition typeAndPid(final int eventType, String pid) { + return allOf(type(eventType), pid(pid)); + } + + /** + * Creates a {@link Condition} to be met by an ConfigurationEvent. + * Checking if a given factoryPid matches the factoryPid and a given + * type matches the type of the Event. + * + * @param eventType the type that would be checked against the type of the + * ConfigurationEvent} + * + * @param factoryPid the factory pid + * @return the condition + */ + public static Condition typeAndFactoryPid(final int eventType, String factoryPid) { + return allOf(type(eventType), factoryPid(factoryPid)); + + } + +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventType.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventType.java new file mode 100644 index 00000000..0116bf36 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/ConfigurationEventType.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.configurationevent; + +import static org.osgi.service.cm.ConfigurationEvent.CM_DELETED; +import static org.osgi.service.cm.ConfigurationEvent.CM_LOCATION_CHANGED; +import static org.osgi.service.cm.ConfigurationEvent.CM_UPDATED; + +import org.osgi.test.common.bitmaps.Bitmap; + +public class ConfigurationEventType { + + private static final int[] TYPES = { + CM_DELETED, CM_LOCATION_CHANGED, CM_UPDATED + }; + + public static String toString(int type) { + switch (type) { + case CM_UPDATED : + return "CM_UPDATED"; + case CM_DELETED : + return "CM_DELETED"; + case CM_LOCATION_CHANGED : + return "CM_LOCATION_CHANGED"; + default : + return Integer.toString(type); + } + } + + public static final Bitmap BITMAP = new Bitmap(TYPES, ConfigurationEventType::toString); +} diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/package-info.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/package-info.java new file mode 100644 index 00000000..05fa6669 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/configurationevent/package-info.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +@org.osgi.annotation.bundle.Export +@org.osgi.annotation.versioning.Version("1.0.0") +package org.osgi.test.assertj.cm.configurationevent; diff --git a/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/package-info.java b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/package-info.java new file mode 100644 index 00000000..5d9a30f3 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/main/java/org/osgi/test/assertj/cm/package-info.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +@org.osgi.annotation.bundle.Export +@org.osgi.annotation.versioning.Version("1.0.0") +package org.osgi.test.assertj.cm; diff --git a/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/ConfigurationEventTypeTest.java b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/ConfigurationEventTypeTest.java new file mode 100644 index 00000000..0e4f02b9 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/ConfigurationEventTypeTest.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.test; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.osgi.service.cm.ConfigurationEvent; +import org.osgi.test.assertj.cm.configurationevent.ConfigurationEventType; + +public class ConfigurationEventTypeTest { + + @Test + void test_toString() throws Exception { + + Assertions.assertThat(ConfigurationEventType.toString(ConfigurationEvent.CM_LOCATION_CHANGED)) + .isSameAs("CM_LOCATION_CHANGED"); + Assertions.assertThat(ConfigurationEventType.toString(ConfigurationEvent.CM_DELETED)) + .isSameAs("CM_DELETED"); + Assertions.assertThat(ConfigurationEventType.toString(ConfigurationEvent.CM_UPDATED)) + .isSameAs("CM_UPDATED"); + + Assertions.assertThat(ConfigurationEventType.toString(999)) + .isEqualTo("999"); + } +} diff --git a/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configuration/ConfigurationEventAssertTest.java b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configuration/ConfigurationEventAssertTest.java new file mode 100644 index 00000000..db9922a8 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configuration/ConfigurationEventAssertTest.java @@ -0,0 +1,143 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.test.configuration; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.osgi.service.cm.Configuration; +import org.osgi.test.assertj.cm.configuration.ConfigurationAssert; +import org.osgi.test.assertj.cm.test.util.AbstractAssertTest; + +class ConfigurationEventAssertTest extends AbstractAssertTest { + + ConfigurationEventAssertTest() { + super(ConfigurationAssert::assertThat); + } + + Configuration event; + + @BeforeEach + void setUp() { + event = mock(Configuration.class); + + setActual(event); + } + + @Test + public void test_hasPid_value() { + + when(event.getPid()).thenReturn(null); + assertPassing(aut::hasPidEqualsTo, (String) null); + + when(event.getPid()).thenReturn("thePid"); + assertPassing(aut::hasPidEqualsTo, "thePid"); + assertFailing(aut::hasPidEqualsTo, "otherPid"); + + } + + @Test + public void test_hasFactoryPid_value() { + + when(event.getFactoryPid()).thenReturn(null); + assertPassing(aut::hasFactoryPidEqualsTo, (String) null); + + when(event.getFactoryPid()).thenReturn("theFactoryPid"); + assertPassing(aut::hasFactoryPidEqualsTo, "theFactoryPid"); + assertFailing(aut::hasFactoryPidEqualsTo, "otherFactoryPid"); + + } + + @Test + public void test_hasNoFactoryPid() { + + when(event.getFactoryPid()).thenReturn(null); + assertPassing(ignores -> aut.hasNoFactoryPid(), null); + + when(event.getFactoryPid()).thenReturn("theFactoryPid"); + assertFailing(ignores -> aut.hasNoFactoryPid(), null); + + } + + @Test + public void test_hasNoPid() { + + when(event.getPid()).thenReturn(null); + assertPassing(ignores -> aut.hasNoPid(), null); + + when(event.getPid()).thenReturn("thePid"); + assertFailing(ignores -> aut.hasNoPid(), null); + + } + + @Test + public void test_hasPid() { + + when(event.getPid()).thenReturn("thePid"); + assertPassing(ignores -> aut.hasPid(), null); + + when(event.getPid()).thenReturn(null); + assertFailing(ignores -> aut.hasPid(), null); + + } + + @Test + public void test_hasFactoryPid() { + + when(event.getFactoryPid()).thenReturn("theFactoryPid"); + assertPassing(ignores -> aut.hasFactoryPid(), null); + + when(event.getFactoryPid()).thenReturn(null); + assertFailing(ignores -> aut.hasFactoryPid(), null); + + } + + @Test + public void test_hasBundleLocation() { + + when(event.getBundleLocation()).thenReturn(null); + assertPassing(aut::hasBundleLocation, (String) null); + + when(event.getPid()).thenReturn("loc"); + assertPassing(aut::hasPidEqualsTo, "loc"); + assertFailing(aut::hasPidEqualsTo, "otherLoc"); + + } + + @Test + public void test_hasChangeCount() { + + when(event.getChangeCount()).thenReturn(1l); + assertPassing(aut::hasChangeCount, 1l); + assertFailing(aut::hasChangeCount, 2l); + + } + + @Test + public void test_hasChangeCountGreater() { + + when(event.getChangeCount()).thenReturn(5l); + assertPassing(aut::hasChangeCountGreater, 4l); + assertFailing(aut::hasChangeCountGreater, 5l); + + } + +} diff --git a/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configurationevent/ConfigurationEventAssertTest.java b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configurationevent/ConfigurationEventAssertTest.java new file mode 100644 index 00000000..edc68b4a --- /dev/null +++ b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configurationevent/ConfigurationEventAssertTest.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.test.configurationevent; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.cm.ConfigurationEvent; +import org.osgi.test.assertj.cm.configurationevent.ConfigurationEventAssert; +import org.osgi.test.assertj.cm.test.util.AbstractAssertTest; + +class ConfigurationEventAssertTest extends AbstractAssertTest { + + ConfigurationEventAssertTest() { + super(ConfigurationEventAssert::assertThat); + } + + ConfigurationEvent event; + + @BeforeEach + void setUp() { + event = mock(ConfigurationEvent.class); + + setActual(event); + } + + @Test + public void test_hasPid_value() { + + when(event.getPid()).thenReturn(null); + assertPassing(aut::hasPidEqualsTo, (String) null); + + when(event.getPid()).thenReturn("thePid"); + assertPassing(aut::hasPidEqualsTo, "thePid"); + assertFailing(aut::hasPidEqualsTo, "otherPid"); + + } + + @Test + public void test_hasFactoryPid_value() { + + when(event.getFactoryPid()).thenReturn(null); + assertPassing(aut::hasFactoryPidEqualsTo, (String) null); + + when(event.getFactoryPid()).thenReturn("theFactoryPid"); + assertPassing(aut::hasFactoryPidEqualsTo, "theFactoryPid"); + assertFailing(aut::hasFactoryPidEqualsTo, "otherFactoryPid"); + + } + + @Test + public void test_hasNoFactoryPid() { + + when(event.getFactoryPid()).thenReturn(null); + assertPassing(ignores -> aut.hasNoFactoryPid(), null); + + when(event.getFactoryPid()).thenReturn("theFactoryPid"); + assertFailing(ignores -> aut.hasNoFactoryPid(), null); + + } + + @Test + public void test_hasNoPid() { + + when(event.getPid()).thenReturn(null); + assertPassing(ignores -> aut.hasNoPid(), null); + + when(event.getPid()).thenReturn("thePid"); + assertFailing(ignores -> aut.hasNoPid(), null); + + } + + @Test + public void test_hasPid() { + + when(event.getPid()).thenReturn("thePid"); + assertPassing(ignores -> aut.hasPid(), null); + + when(event.getPid()).thenReturn(null); + assertFailing(ignores -> aut.hasPid(), null); + + } + + @Test + public void test_hasFactoryPid() { + + when(event.getFactoryPid()).thenReturn("theFactoryPid"); + assertPassing(ignores -> aut.hasFactoryPid(), null); + + when(event.getFactoryPid()).thenReturn(null); + assertFailing(ignores -> aut.hasFactoryPid(), null); + + } + + @Test + public void test_hasType() { + + when(event.getType()).thenReturn(ConfigurationEvent.CM_DELETED); + assertPassing(aut::hasTypeEqualTo, ConfigurationEvent.CM_DELETED); + assertFailing(aut::hasTypeEqualTo, ConfigurationEvent.CM_UPDATED); + assertFailing(aut::hasTypeEqualTo, ConfigurationEvent.CM_LOCATION_CHANGED); + + when(event.getType()).thenReturn(ConfigurationEvent.CM_UPDATED); + assertPassing(aut::hasTypeEqualTo, ConfigurationEvent.CM_UPDATED); + assertFailing(aut::hasTypeEqualTo, ConfigurationEvent.CM_DELETED); + assertFailing(aut::hasTypeEqualTo, ConfigurationEvent.CM_LOCATION_CHANGED); + + when(event.getType()).thenReturn(ConfigurationEvent.CM_LOCATION_CHANGED); + assertPassing(aut::hasTypeEqualTo, ConfigurationEvent.CM_LOCATION_CHANGED); + assertFailing(aut::hasTypeEqualTo, ConfigurationEvent.CM_UPDATED); + assertFailing(aut::hasTypeEqualTo, ConfigurationEvent.CM_DELETED); + + } + + @Test + public void test_hasReference() { + ServiceReference sr = mock(ServiceReference.class); + ServiceReference otherSr = mock(ServiceReference.class); + + when(event.getReference()).thenReturn(sr); + + aut.hasReferenceThat() + .isEqualTo(sr); + + assertThatThrownBy(() -> { + aut.hasReferenceThat() + .isEqualTo(otherSr); + }); + + } +} diff --git a/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configurationevent/ConfigurationEventConditionsTest.java b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configurationevent/ConfigurationEventConditionsTest.java new file mode 100644 index 00000000..5ffc7aa3 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/configurationevent/ConfigurationEventConditionsTest.java @@ -0,0 +1,185 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.test.configurationevent; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.jupiter.api.BeforeEach; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationEvent; +import org.osgi.test.assertj.cm.configurationevent.ConfigurationEventConditions; +import org.osgi.test.assertj.cm.test.util.ConditionAssert; + +class ConfigurationEventConditionsTest implements ConditionAssert { + + class A {} + + @SuppressWarnings("rawtypes") + ConfigurationEvent configurationEvent; + + @BeforeEach + private void beforEach() { + configurationEvent = mock(ConfigurationEvent.class, "configurationEvent"); + } + + @SuppressWarnings("unchecked") + @org.junit.jupiter.api.Test + public void test_factoryPid_String() throws Exception { + + when(configurationEvent.getFactoryPid()).thenReturn("theFactoryPid"); + passingHas(ConfigurationEventConditions.factoryPid("theFactoryPid"), configurationEvent); + + when(configurationEvent.getFactoryPid()).thenReturn("otherFactoryPid"); + failingHas(ConfigurationEventConditions.factoryPid("theFactoryPid"), configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + "factoryPid equals .* was ")); + + when(configurationEvent.getFactoryPid()).thenReturn(null); + failingHas(ConfigurationEventConditions.factoryPid("theFactoryPid"), configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + "factoryPid equals .* was ")); + + } + + + @SuppressWarnings("unchecked") + @org.junit.jupiter.api.Test + public void test_factoryPidNull() throws Exception { + + when(configurationEvent.getFactoryPid()).thenReturn(null); + passingHas(ConfigurationEventConditions.factoryPidNull(), configurationEvent); + + when(configurationEvent.getFactoryPid()).thenReturn("theFactoryPid"); + failingHas(ConfigurationEventConditions.factoryPidNull(), configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + "factoryPid is .*was ")); + + } + + @org.junit.jupiter.api.Test + public void test_pidNull() throws Exception { + + when(configurationEvent.getPid()).thenReturn(null); + passingHas(ConfigurationEventConditions.pidNull(), configurationEvent); + + when(configurationEvent.getPid()).thenReturn("thePid"); + failingHas(ConfigurationEventConditions.pidNull(), configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + "pid is .*was ")); + + } + + + @org.junit.jupiter.api.Test + public void test_pid_String() throws Exception { + + when(configurationEvent.getFactoryPid()).thenReturn("thePid"); + passingHas(ConfigurationEventConditions.factoryPid("thePid"), configurationEvent); + + when(configurationEvent.getFactoryPid()).thenReturn("otherPid"); + failingHas(ConfigurationEventConditions.factoryPid("thePid"), configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + "pid equals .* was ")); + + when(configurationEvent.getFactoryPid()).thenReturn(null); + failingHas(ConfigurationEventConditions.factoryPid("thePid"), configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + "pid equals .* was ")); + + } + + @org.junit.jupiter.api.Test + public void test_matches() throws Exception { + Configuration configuration = mock(Configuration.class); + + when(configuration.getFactoryPid()).thenReturn("theFactoryPid"); + when(configuration.getPid()).thenReturn(null); + when(configurationEvent.getFactoryPid()).thenReturn("theFactoryPid"); + when(configurationEvent.getPid()).thenReturn(null); + passingHas(ConfigurationEventConditions.matches(configuration), configurationEvent); + + when(configuration.getFactoryPid()).thenReturn(null); + when(configuration.getPid()).thenReturn("thePid"); + when(configurationEvent.getFactoryPid()).thenReturn(null); + when(configurationEvent.getPid()).thenReturn("thePid"); + passingHas(ConfigurationEventConditions.matches(configuration), configurationEvent); + + when(configuration.getFactoryPid()).thenReturn("theFactoryPid"); + when(configuration.getPid()).thenReturn(null); + when(configurationEvent.getFactoryPid()).thenReturn("otherFactoryPid"); + when(configurationEvent.getPid()).thenReturn(null); + failingHas(ConfigurationEventConditions.matches(configuration), configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + + "any of.*not :>.*factoryPid equals was .*")); + + when(configuration.getFactoryPid()).thenReturn(null); + when(configuration.getPid()).thenReturn("thePid"); + when(configurationEvent.getFactoryPid()).thenReturn(null); + when(configurationEvent.getPid()).thenReturn("otherPid"); + failingHas(ConfigurationEventConditions.matches(configuration), configurationEvent).hasMessageMatching( + (regex_startWith_Expecting + + "any of.*not : was >,.*was .*not :>.*")); + + } + + @org.junit.jupiter.api.Test + public void test_typeAndPid() throws Exception { + + when(configurationEvent.getType()).thenReturn(ConfigurationEvent.CM_UPDATED); + when(configurationEvent.getPid()).thenReturn("thePid"); + passingHas(ConfigurationEventConditions.typeAndPid(ConfigurationEvent.CM_UPDATED, "thePid"), + configurationEvent); + + failingHas(ConfigurationEventConditions.typeAndPid(ConfigurationEvent.CM_UPDATED, "otherPid"), + configurationEvent).hasMessageMatching( + (regex_startWith_Expecting + "all of.*type is .*pid equals .*was.*.*")); + + failingHas(ConfigurationEventConditions.typeAndPid(ConfigurationEvent.CM_DELETED, "thePid"), configurationEvent) + .hasMessageMatching( + (regex_startWith_Expecting + "all of.*type is .*was .*pid equals .*")); + + } + + @org.junit.jupiter.api.Test + public void test_typeAndFactoryPid() throws Exception { + + when(configurationEvent.getType()).thenReturn(ConfigurationEvent.CM_UPDATED); + when(configurationEvent.getFactoryPid()).thenReturn("theFactoryPid"); + passingHas(ConfigurationEventConditions.typeAndFactoryPid(ConfigurationEvent.CM_UPDATED, "theFactoryPid"), + configurationEvent); + + failingHas(ConfigurationEventConditions.typeAndFactoryPid(ConfigurationEvent.CM_UPDATED, "otherFactoryPid"), + configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + + "all of.*type is .*factoryPid equals .*was.*.*")); + + failingHas(ConfigurationEventConditions.typeAndFactoryPid(ConfigurationEvent.CM_DELETED, "theFactoryPid"), + configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + + "all of.*type is .*was .*factoryPid equals .*")); + + } + + @org.junit.jupiter.api.Test + public void test_type() throws Exception { + + when(configurationEvent.getType()).thenReturn(ConfigurationEvent.CM_UPDATED); + passingHas(ConfigurationEventConditions.type(ConfigurationEvent.CM_UPDATED), configurationEvent); + + when(configurationEvent.getType()).thenReturn(ConfigurationEvent.CM_DELETED); + failingHas(ConfigurationEventConditions.type(ConfigurationEvent.CM_UPDATED), configurationEvent) + .hasMessageMatching((regex_startWith_Expecting + "type is .*was.*")); + + } +} diff --git a/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/AbstractAssertTest.java b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/AbstractAssertTest.java new file mode 100644 index 00000000..e2b80b1a --- /dev/null +++ b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/AbstractAssertTest.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.test.util; + +import org.assertj.core.api.Assert; +import org.assertj.core.api.AssertFactory; +import org.assertj.core.api.SoftAssertions; +import org.assertj.core.api.junit.jupiter.InjectSoftAssertions; +import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith(SoftAssertionsExtension.class) +public abstract class AbstractAssertTest, ACTUAL> + implements AssertTest { + + protected final AssertFactory assertThat; + protected ACTUAL actual; + protected SELF aut; + @InjectSoftAssertions + SoftAssertions softly; + + protected AbstractAssertTest(AssertFactory assertThat) { + this.assertThat = assertThat; + } + + @Override + public ACTUAL actual() { + return actual; + } + + @Override + public SELF aut() { + return aut; + } + + @Override + public SoftAssertions softly() { + return softly; + } + + protected void setActual(ACTUAL actual) { + this.actual = actual; + aut = assertThat.createAssert(actual); + } +} diff --git a/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/AssertTest.java b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/AssertTest.java new file mode 100644 index 00000000..17fba581 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/AssertTest.java @@ -0,0 +1,196 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.test.util; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; +import java.util.function.Supplier; + +import org.assertj.core.api.AbstractAssert; +import org.assertj.core.api.AbstractThrowableAssert; +import org.assertj.core.api.Assert; +import org.assertj.core.api.Assertions; +import org.assertj.core.api.SoftAssertions; +import org.assertj.core.api.SoftAssertionsProvider; +import org.opentest4j.AssertionFailedError; +import org.osgi.test.common.exceptions.Exceptions; + +public interface AssertTest, ACTUAL> { + + /** + * Returns the actual object + * + * @return The actual object that our assertion-under-test is asserting on. + */ + ACTUAL actual(); + + /** + * Returns the Assertion Under Test (AUT). + * + * @return The assertion under test + */ + SELF aut(); + + /** + * @return The soft assertions object used for the current tests. + */ + SoftAssertions softly(); + + @SuppressWarnings("unchecked") + default void softAssertionsProvider(Class sap) throws Exception { + softAssertionsProvider(sap, (Class) actual().getClass()); + } + // Tests that the SoftAssertionsProvider is "properly implemented". + // Definition of "properly implemented": + // - Contains an "assertThat" method with the appropriate parameter and + // return type. + // - Checks that this assertThat() method invokes proxy() with the + // appropriate arguments. + // - Checks that this assertThat() method returns the result that proxy() + // returns. + default void softAssertionsProvider(Class sap, Class actualClass) + throws Exception { + + AtomicReference m = new AtomicReference<>(); + Assertions.assertThatCode(() -> m.set(sap.getMethod("assertThat", actualClass))) + .doesNotThrowAnyException(); + + Assertions.assertThat(m.get() + .getReturnType()) + .as("returnType") + .isEqualTo(aut().getClass()); + + SAP sapInstance = spy(sap); + + when(sapInstance.proxy(any(), any(), any())).thenReturn(aut()); + + Object retval = m.get() + .invoke(sapInstance, actual()); + + // Check that the returned assertion from assertThat() is the one + // returned by proxy(). + softly().assertThat(retval) + .as("returnedAssertion") + .isSameAs(aut()); + + doVerify(sapInstance, actualClass); + } + + // Delegated to another method to reduce the scope of the @SuppressWarnings + // to the minimum required. + @SuppressWarnings("unchecked") + default void doVerify(SoftAssertionsProvider sapInstance, Class actualClass) { + verify(sapInstance).proxy((Class) aut().getClass(), actualClass, actual()); + } + + default AbstractThrowableAssert assertEqualityAssertion(String field, Function assertion, + T actual, T failing) { + return assertEqualityAssertion(null, field, assertion, actual, failing); + } + + /** + * Routine containing boilerplate code for checking correct assertion + * behavior. This function calls {@link #assertPassing assertPassing()} and + * {@link #assertFailing assertFailing()}. It also asserts that the failure + * message matches the general pattern "expected <%s>, but was <%s>". It + * returns the {@link AbstractThrowableAssert} instance so that you can + * perform further assertions on the exception. + * + * @param the type of the arguments accepted by the assertion method + * under test. + * @param softly the {@code SoftAssertions} object passed in to the original + * test message. + * @param assertion reference to the assertion method of the {@link #aut()} + * @param actual the value that the method under test will actually return. + * @param failing an argument to pass to the assertion method that should + * fail. + * @return The {@code AbstractThrowableAssert} instance used for chaining + * further assertions. + */ + default AbstractThrowableAssert assertEqualityAssertion(String msg, String field, + Function assertion, T actual, T failing) { + assertPassing(msg, assertion, actual); + AbstractThrowableAssert retval = assertFailing(msg, assertion, failing) + .hasMessageMatching("(?si).*expecting.*" + field + ".*" + failing + ".*but.*was.*" + actual + ".*") + .isInstanceOf(AssertionFailedError.class); + try { + Field f = AbstractAssert.class.getDeclaredField("actual"); + f.setAccessible(true); + Object a = f.get(retval); + if (!(a instanceof AssertionFailedError)) { + return retval; + } + AssertionFailedError afe = (AssertionFailedError) a; + softly().assertThat(afe.getActual() + .getStringRepresentation()) + .as("actual") + .isEqualTo(String.valueOf(actual)); + softly().assertThat(afe.getExpected() + .getStringRepresentation()) + .as("expected") + .isEqualTo(String.valueOf(failing)); + } catch (Exception e) { + throw Exceptions.duck(e); + } + return retval; + } + + default void assertPassing(Function assertion, T passing) { + assertPassing(null, assertion, passing); + } + + default void assertPassing(String msg, Function assertion, T passing) { + AtomicReference retval = new AtomicReference<>(); + softly().assertThatCode(() -> retval.set(assertion.apply(passing))) + .as(msg == null ? "passing" : msg + ":passing") + .doesNotThrowAnyException(); + if (softly().wasSuccess()) { + softly().assertThat(retval.get()) + .as(msg == null ? "chaining" : msg + ":chaining") + .isSameAs(aut()); + } + } + + default AbstractThrowableAssert assertFailing(Function assertion, T failing) { + return assertFailing(null, assertion, failing); + } + + default AbstractThrowableAssert assertFailing(String msg, Function assertion, T failing) { + return softly().assertThatThrownBy(() -> assertion.apply(failing)) + .as(msg == null ? "failing" : msg + ":failing") + .isInstanceOf(AssertionError.class) + .hasMessageContaining(actual().toString()); + } + + default > void assertChildAssertion(String msg, + Supplier childSupplier, Supplier field) { + CHILD child = childSupplier.get(); + softly().assertThat(child) + .extracting("actual") + .as(msg == null ? "child" : msg + ":child") + .isEqualTo(field.get()); + } +} diff --git a/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/ConditionAssert.java b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/ConditionAssert.java new file mode 100644 index 00000000..6ff01ad8 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/ConditionAssert.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.test.util; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import java.util.regex.Pattern; + +import org.assertj.core.api.AbstractThrowableAssert; +import org.assertj.core.api.Condition; +import org.assertj.core.api.ObjectAssertFactory; + +public interface ConditionAssert { + String regex_startWith_Expecting = "(?si).*Expecting.*"; + + default AbstractThrowableAssert failingHas(Condition condition, T actual, String msg, Object... args) { + return failingHas(condition, actual, String.format(msg, args)); + } + + default AbstractThrowableAssert failingHas(Condition condition, T actual, String msg) { + String regex = regex_expecting_X_M_Y(actual, ConditionMethod.Has, msg); + return failingHas(condition, actual).hasMessageMatching(regex); + } + + default AbstractThrowableAssert failingHas(Condition condition, T actual) { + return assertThatThrownBy(() -> passingHas(condition, actual)).isInstanceOf(AssertionError.class); + } + + default AbstractThrowableAssert failingIs(Condition condition, T actual, String msg, Object... args) { + return failingIs(condition, actual, String.format(msg, args)); + } + + default AbstractThrowableAssert failingIs(Condition condition, T actual, String msg) { + String regex = regex_expecting_X_M_Y(actual, ConditionMethod.Is, msg); + return assertThatThrownBy(() -> passingIs(condition, actual)).isInstanceOf(AssertionError.class) + .hasMessageMatching(regex); + } + + default void passingHas(Condition condition, T actual) { + ObjectAssertFactory factory = new ObjectAssertFactory<>(); + factory.createAssert(actual) + .has(condition); + } + + default void passingIs(Condition condition, T actual) { + ObjectAssertFactory factory = new ObjectAssertFactory<>(); + factory.createAssert(actual) + .is(condition); + } + + default String regex_expecting_X_M_Y(Object x, ConditionMethod m, Object y) { + return String.format(regex_startWith_Expecting + "%s.*" + m + ".*%s.*", Pattern.quote(x.toString()), y); + } + + default String regex_expecting_X_M_Y_Z(Object x, ConditionMethod m, Object y, Object z) { + return regex_expecting_X_M_Y(x, m, String.format("%s.*%s", y, z)); + } + +} \ No newline at end of file diff --git a/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/ConditionMethod.java b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/ConditionMethod.java new file mode 100644 index 00000000..0ec250d6 --- /dev/null +++ b/org.osgi.test.assertj.cm/src/test/java/org/osgi/test/assertj/cm/test/util/ConditionMethod.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.cm.test.util; + +public enum ConditionMethod { + + Has("to have"), + DoesNotHas("not to have"), + Is("to be"), + IsNot("not to be"); + + private String text; + + ConditionMethod(String text) { + this.text = text; + } + + @Override + public String toString() { + + return text; + } +} \ No newline at end of file diff --git a/org.osgi.test.assertj.cm/test.bndrun b/org.osgi.test.assertj.cm/test.bndrun new file mode 100644 index 00000000..4999fd05 --- /dev/null +++ b/org.osgi.test.assertj.cm/test.bndrun @@ -0,0 +1,46 @@ +# Copyright (c) OSGi Alliance (2019, 2020). All Rights Reserved. +# +# 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. + +-tester: biz.aQute.tester.junit-platform + +-runvm: ${def;argLine} + +-runfw: org.eclipse.osgi +-resolve.effective: active +-runproperties: \ + logback.configurationFile=${fileuri;${.}/logback.xml},\ + org.apache.felix.http.host=localhost,\ + org.osgi.service.http.port=*,\ + org.osgi.framework.bootdelegation=sun.reflect,\ + osgi.console= + +-runsystempackages: \ + org.slf4j;version=1.7.25,\ + org.slf4j.helpers;version=1.7.25,\ + org.slf4j.spi;version=1.7.25 +-runpath: \ + ch.qos.logback.classic,\ + ch.qos.logback.core,\ + org.apache.felix.logback,\ + slf4j.api +-runrequires: \ + bnd.identity;id='${project.artifactId}-tests',\ + bnd.identity;id='junit-jupiter-engine',\ + bnd.identity;id='junit-platform-launcher' +# This will help us keep -runbundles sorted +-runstartlevel: \ + order=sortbynameversion,\ + begin=-1 +-runee: JavaSE-1.8 +# -runbundles is calculated by the bnd-resolver-maven-plugin diff --git a/org.osgi.test.assertj.framework/src/test/java/org/osgi/test/assertj/test/testutil/ConditionAssert.java b/org.osgi.test.assertj.framework/src/test/java/org/osgi/test/assertj/test/testutil/ConditionAssert.java new file mode 100644 index 00000000..4dbbee0d --- /dev/null +++ b/org.osgi.test.assertj.framework/src/test/java/org/osgi/test/assertj/test/testutil/ConditionAssert.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.test.testutil; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import java.util.regex.Pattern; + +import org.assertj.core.api.AbstractThrowableAssert; +import org.assertj.core.api.Condition; +import org.assertj.core.api.ObjectAssertFactory; + +public interface ConditionAssert { + String regex_startWith_Expecting = "(?si).*Expecting.*"; + + default AbstractThrowableAssert failingHas(Condition condition, T actual, String msg, Object... args) { + return failingHas(condition, actual, String.format(msg, args)); + } + + default AbstractThrowableAssert failingHas(Condition condition, T actual, String msg) { + String regex = regex_expecting_X_M_Y(actual, ConditionMethod.Has, msg); + return failingHas(condition, actual).hasMessageMatching(regex); + } + + default AbstractThrowableAssert failingHas(Condition condition, T actual) { + return assertThatThrownBy(() -> passingHas(condition, actual)).isInstanceOf(AssertionError.class); + } + + default AbstractThrowableAssert failingIs(Condition condition, T actual, String msg, Object... args) { + return failingIs(condition, actual, String.format(msg, args)); + } + + default AbstractThrowableAssert failingIs(Condition condition, T actual, String msg) { + String regex = regex_expecting_X_M_Y(actual, ConditionMethod.Is, msg); + return assertThatThrownBy(() -> passingIs(condition, actual)).isInstanceOf(AssertionError.class) + .hasMessageMatching(regex); + } + + default void passingHas(Condition condition, T actual) { + ObjectAssertFactory factory = new ObjectAssertFactory<>(); + factory.createAssert(actual) + .has(condition); + } + + default void passingIs(Condition condition, T actual) { + ObjectAssertFactory factory = new ObjectAssertFactory<>(); + factory.createAssert(actual) + .is(condition); + } + + default String regex_expecting_X_M_Y(Object x, ConditionMethod m, Object y) { + return String.format(regex_startWith_Expecting + "%s.*" + m + ".*%s.*", Pattern.quote(x.toString()), y); + } + + default String regex_expecting_X_M_Y_Z(Object x, ConditionMethod m, Object y, Object z) { + return regex_expecting_X_M_Y(x, m, String.format("%s.*%s", y, z)); + } + +} \ No newline at end of file diff --git a/org.osgi.test.assertj.framework/src/test/java/org/osgi/test/assertj/test/testutil/ConditionMethod.java b/org.osgi.test.assertj.framework/src/test/java/org/osgi/test/assertj/test/testutil/ConditionMethod.java new file mode 100644 index 00000000..75f5d62c --- /dev/null +++ b/org.osgi.test.assertj.framework/src/test/java/org/osgi/test/assertj/test/testutil/ConditionMethod.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) Contributors to the Eclipse Foundation + * + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + *******************************************************************************/ + +package org.osgi.test.assertj.test.testutil; + +public enum ConditionMethod { + + Has("to have"), + DoesNotHas("not to have"), + Is("to be"), + IsNot("not to be"); + + private String text; + + ConditionMethod(String text) { + this.text = text; + } + + @Override + public String toString() { + + return text; + } +} \ No newline at end of file diff --git a/org.osgi.test.bom/pom.xml b/org.osgi.test.bom/pom.xml index 9e9cf77c..f6cc65c2 100644 --- a/org.osgi.test.bom/pom.xml +++ b/org.osgi.test.bom/pom.xml @@ -49,6 +49,12 @@ ${project.version} test + + org.osgi + org.osgi.test.assertj.cm + ${project.version} + test + org.osgi org.osgi.test.assertj.framework diff --git a/org.osgi.test.junit5.cm/test.bndrun b/org.osgi.test.junit5.cm/test.bndrun index 0d528f29..e8ab6ca7 100644 --- a/org.osgi.test.junit5.cm/test.bndrun +++ b/org.osgi.test.junit5.cm/test.bndrun @@ -42,4 +42,5 @@ -runstartlevel: \ order=sortbynameversion,\ begin=-1 + # -runbundles is calculated by the bnd-resolver-maven-plugin diff --git a/pom.xml b/pom.xml index fa110cfb..f1b162ae 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,7 @@ org.osgi.test.assertj.framework org.osgi.test.assertj.log org.osgi.test.assertj.promise + org.osgi.test.assertj.cm org.osgi.test.junit4 org.osgi.test.junit5 org.osgi.test.junit5.cm