-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make state transitions sync (#3313)
* feat: make state transitions sync * PR remarks * Add decision record * PR remarks
- Loading branch information
Showing
125 changed files
with
2,885 additions
and
2,557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ore/src/test/java/org/eclipse/edc/connector/core/base/CommandHandlerRegistryImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.connector.core.base; | ||
|
||
import org.eclipse.edc.spi.command.CommandFailure; | ||
import org.eclipse.edc.spi.command.CommandHandler; | ||
import org.eclipse.edc.spi.command.CommandResult; | ||
import org.eclipse.edc.spi.command.EntityCommand; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat; | ||
import static org.eclipse.edc.spi.command.CommandFailure.Reason.NOT_EXECUTABLE; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class CommandHandlerRegistryImplTest { | ||
|
||
private final CommandHandler<?> handler = mock(); | ||
private final CommandHandlerRegistryImpl registry = new CommandHandlerRegistryImpl(); | ||
|
||
@Test | ||
void execute_shouldExecuteCommand() { | ||
doReturn(TestCommand.class).when(handler).getType(); | ||
when(handler.handle(any())).thenReturn(CommandResult.success()); | ||
registry.register(handler); | ||
var command = new TestCommand("id"); | ||
|
||
var result = registry.execute(command); | ||
|
||
assertThat(result).isSucceeded(); | ||
} | ||
|
||
@Test | ||
void execute_shouldReturnFailure_whenCommandHandlerNotFound() { | ||
var command = new TestCommand("id"); | ||
|
||
var result = registry.execute(command); | ||
|
||
assertThat(result).isFailed().extracting(CommandFailure::getReason).isEqualTo(NOT_EXECUTABLE); | ||
} | ||
|
||
private static class TestCommand extends EntityCommand { | ||
|
||
TestCommand(String entityId) { | ||
super(entityId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...re/src/main/java/org/eclipse/edc/validator/jsonobject/validators/MandatoryIdNotBlank.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.validator.jsonobject.validators; | ||
|
||
import jakarta.json.JsonString; | ||
import org.eclipse.edc.validator.jsonobject.JsonLdPath; | ||
import org.eclipse.edc.validator.spi.ValidationResult; | ||
import org.eclipse.edc.validator.spi.Validator; | ||
|
||
import static java.lang.String.format; | ||
import static org.eclipse.edc.validator.spi.Violation.violation; | ||
|
||
/** | ||
* Verify that the @id field is not null or blank. | ||
*/ | ||
public class MandatoryIdNotBlank implements Validator<JsonString> { | ||
|
||
private final JsonLdPath path; | ||
|
||
public MandatoryIdNotBlank(JsonLdPath path) { | ||
this.path = path; | ||
} | ||
|
||
@Override | ||
public ValidationResult validate(JsonString id) { | ||
if (id == null || id.getString().isBlank()) { | ||
return ValidationResult.failure(violation(format("%s cannot be null or blank", path), path.toString())); | ||
} else { | ||
return ValidationResult.success(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.