Skip to content
Open
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
46 changes: 46 additions & 0 deletions shopping-cart-v2/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
pipeline {
agent { node { label 'maven' } }
environment { APP_NAMESPACE = 'ebomqy-recover' }
stages {
stage('Test') {
//options { timeout(time: 50, unit: 'SECONDS') }
steps {
dir('shopping-cart-v2') {
sh './mvnw clean test'
}
}
}
stage('Build Image') {
environment { QUAY = credentials('QUAY_USER') }
steps {
dir('shopping-cart-v2') {
sh './scripts/include-container-extensions.sh'
sh '''
./scripts/build-and-push-image.sh \
-u $QUAY_USR \
-p $QUAY_PSW \
-b $BUILD_NUMBER
'''
}
}
}
stage('Deploy') {
environment { QUAY = credentials('QUAY_USER') }
steps {
dir('shopping-cart-v2') {
script {
def status = sh(
script: "./scripts/tag-exists-in-quay.sh $QUAY_USR/do400-recover latest",
returnStatus: true
)
if (status != 0) {
error("Tag not found in Quay!")
}
}
sh './scripts/redeploy.sh $APP_NAMESPACE'
}
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
@QuarkusTest
@Tag("integration")
public class ShoppingCartTest {

@BeforeAll
public static void setup() {
CatalogStorage mockStorage = Mockito.mock(InMemoryCatalogStorage.class);

Mockito.when(mockStorage.containsKey(1)).thenReturn(true);
Mockito.when(mockStorage.containsKey(2)).thenReturn(true);
Mockito.when(mockStorage.containsKey(9999)).thenReturn(false);

Mockito.when(mockStorage.get(1)).thenReturn(new Product(1, 100));
Mockito.when(mockStorage.get(2)).thenReturn(new Product(2, 200));

QuarkusMock.installMockForType(mockStorage, CatalogStorage.class);
}

private int randomQuantity() {
return (new Random()).nextInt(10) + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public class ShoppingCartTest {

@Inject
CartService cartService;

@BeforeAll
public static void setup() {
CatalogStorage mockStorage = Mockito.mock(InMemoryCatalogStorage.class);

Mockito.when(mockStorage.containsKey(1)).thenReturn(true);
Mockito.when(mockStorage.containsKey(9999)).thenReturn(false);

Mockito.when(mockStorage.get(1)).thenReturn(new Product(1, 100));

QuarkusMock.installMockForType(mockStorage, CatalogStorage.class);
}

@BeforeEach
void clearCart() {
Expand Down