-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Antoine MAZEAS <[email protected]>
- Loading branch information
1 parent
c4bec76
commit 8246a4d
Showing
4 changed files
with
92 additions
and
0 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
16 changes: 16 additions & 0 deletions
16
openbas-api/src/test/java/io/openbas/utils/fixtures/VariableFixture.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,16 @@ | ||
package io.openbas.utils.fixtures; | ||
|
||
import io.openbas.database.model.Variable; | ||
|
||
import java.util.UUID; | ||
|
||
public class VariableFixture { | ||
public static Variable getVariable() { | ||
Variable var = new Variable(); | ||
var.setId(UUID.randomUUID().toString()); | ||
var.setKey("variable_key"); | ||
var.setValue("variable value"); | ||
var.setDescription("variable description"); | ||
return var; | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
openbas-api/src/test/java/io/openbas/utils/fixtures/composers/VariableComposer.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,38 @@ | ||
package io.openbas.utils.fixtures.composers; | ||
|
||
import io.openbas.database.model.Variable; | ||
import io.openbas.database.repository.VariableRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Component | ||
public class VariableComposer extends ComposerBase<Variable> { | ||
@Autowired private VariableRepository variableRepository; | ||
|
||
public class Composer extends InnerComposerBase<Variable> { | ||
private final Variable variable; | ||
|
||
public Composer(Variable variable) { | ||
this.variable = variable; | ||
} | ||
|
||
@Override | ||
public Composer persist() { | ||
variableRepository.save(variable); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Variable get() { | ||
return this.variable; | ||
} | ||
} | ||
|
||
public Composer forVariable(Variable variable) { | ||
generatedItems.add(variable); | ||
return new Composer(variable); | ||
} | ||
} |