Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public void setError(String error) {
}

public boolean isError() {
return error == null;
return error != null;
}

public String getDependencyConflictId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.repository.metadata;

import org.apache.maven.artifact.ArtifactScopeEnum;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Regression test for {@link ArtifactMetadata#isError()}.
* Verifies that isError() returns true when error is set, false when error is null.
*/
@Deprecated
class ArtifactMetadataTest {

@Test
void isErrorReturnsFalseWhenErrorIsNull() {
ArtifactMetadata metadata = new ArtifactMetadata("g:a:1.0");
assertFalse(metadata.isError());
}

@Test
void isErrorReturnsTrueWhenErrorIsSet() {
ArtifactMetadata metadata = new ArtifactMetadata("g:a:1.0");
metadata.setError("Something went wrong");
assertTrue(metadata.isError());
}

@Test
void isErrorReturnsFalseAfterErrorIsCleared() {
ArtifactMetadata metadata = new ArtifactMetadata("g:a:1.0");
metadata.setError("Something went wrong");
metadata.setError(null);
assertFalse(metadata.isError());
}

@Test
void isErrorReturnsTrueWhenConstructedWithError() {
ArtifactMetadata metadata = new ArtifactMetadata(
"g", "a", "1.0", "jar", ArtifactScopeEnum.DEFAULT_SCOPE, null, null, null, false, "Resolution failed");
assertTrue(metadata.isError());
}

@Test
void isErrorReturnsFalseWhenConstructedWithoutError() {
ArtifactMetadata metadata = new ArtifactMetadata(
"g", "a", "1.0", "jar", ArtifactScopeEnum.DEFAULT_SCOPE, null, null, null, true, null);
assertFalse(metadata.isError());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,7 @@ private boolean validateProfileId(
String id,
@Nullable SourceHint sourceHint,
InputLocationTracker tracker) {
if (validProfileIds.contains(id)) {
if (id != null && validProfileIds.contains(id)) {
return true;
}
if (!validateStringNotEmpty(prefix, fieldName, problems, severity, version, id, sourceHint, tracker)) {
Expand Down
Loading