-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
143 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...s/models/src/main/java/org/eclipse/xpanse/modules/models/servicetemplate/FlavorBasic.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,30 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* SPDX-FileCopyrightText: Huawei Inc. | ||
*/ | ||
|
||
package org.eclipse.xpanse.modules.models.servicetemplate; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Data; | ||
|
||
/** | ||
* Defines for service flavor. | ||
*/ | ||
@Data | ||
public class FlavorBasic { | ||
|
||
@NotNull | ||
@NotBlank | ||
@NotEmpty | ||
@Schema(description = "The flavor name") | ||
private String name; | ||
|
||
@NotNull | ||
@Schema(description = "The price of the flavor") | ||
private Integer fixedPrice; | ||
|
||
} |
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
77 changes: 77 additions & 0 deletions
77
...dels/src/test/java/org/eclipse/xpanse/modules/models/servicetemplate/FlavorBasicTest.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,77 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* SPDX-FileCopyrightText: Huawei Inc. | ||
* | ||
*/ | ||
|
||
package org.eclipse.xpanse.modules.models.servicetemplate; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Test of FlavorBasic. | ||
*/ | ||
class FlavorBasicTest { | ||
|
||
private static final String name = "flavor"; | ||
private static final Integer fixedPrice = 1; | ||
private static FlavorBasic flavorBasic; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
flavorBasic = new FlavorBasic(); | ||
flavorBasic.setName(name); | ||
flavorBasic.setFixedPrice(fixedPrice); | ||
} | ||
|
||
@Test | ||
void testGetterAndSetter() { | ||
assertEquals(name, flavorBasic.getName()); | ||
assertEquals(fixedPrice, flavorBasic.getFixedPrice()); | ||
} | ||
|
||
@Test | ||
void testEqualsAndHashCode() { | ||
assertEquals(flavorBasic, flavorBasic); | ||
assertEquals(flavorBasic.hashCode(), flavorBasic.hashCode()); | ||
|
||
Object obj = new Object(); | ||
assertNotEquals(flavorBasic, obj); | ||
assertNotEquals(flavorBasic, null); | ||
assertNotEquals(flavorBasic.hashCode(), obj.hashCode()); | ||
|
||
FlavorBasic flavorBasic1 = new FlavorBasic(); | ||
FlavorBasic flavorBasic2 = new FlavorBasic(); | ||
assertNotEquals(flavorBasic, flavorBasic1); | ||
assertNotEquals(flavorBasic, flavorBasic2); | ||
assertEquals(flavorBasic1, flavorBasic2); | ||
assertNotEquals(flavorBasic.hashCode(), flavorBasic1.hashCode()); | ||
assertNotEquals(flavorBasic.hashCode(), flavorBasic2.hashCode()); | ||
assertEquals(flavorBasic1.hashCode(), flavorBasic2.hashCode()); | ||
|
||
flavorBasic1.setName(name); | ||
assertNotEquals(flavorBasic, flavorBasic1); | ||
assertNotEquals(flavorBasic1, flavorBasic2); | ||
assertNotEquals(flavorBasic.hashCode(), flavorBasic1.hashCode()); | ||
assertNotEquals(flavorBasic1.hashCode(), flavorBasic2.hashCode()); | ||
|
||
flavorBasic1.setFixedPrice(fixedPrice); | ||
assertEquals(flavorBasic, flavorBasic1); | ||
assertNotEquals(flavorBasic1, flavorBasic2); | ||
assertEquals(flavorBasic.hashCode(), flavorBasic1.hashCode()); | ||
assertNotEquals(flavorBasic1.hashCode(), flavorBasic2.hashCode()); | ||
} | ||
|
||
@Test | ||
void testToString() { | ||
String expectedString = "FlavorBasic(" + | ||
"name=" + name + | ||
", fixedPrice=" + fixedPrice + ")"; | ||
assertEquals(expectedString, flavorBasic.toString()); | ||
} | ||
|
||
} |
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