Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 253406c

Browse files
authored
Merge pull request #627 from southworks/southworks/OAuth-toAttachment
Add test for toAttachment methods in Card's classes
2 parents 88ee6ea + 8b4237a commit 253406c

File tree

8 files changed

+243
-0
lines changed

8 files changed

+243
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.microsoft.bot.schema;
5+
6+
import java.util.ArrayList;
7+
import org.junit.Assert;
8+
import org.junit.Test;
9+
10+
/***
11+
* Tests to ensure the AnimationCard methods work as expected.
12+
*/
13+
public class AnimationCardTest {
14+
ArrayList<MediaUrl> media = new ArrayList<MediaUrl>();
15+
16+
AnimationCard card = new AnimationCard(){
17+
{
18+
setText("Test Animation Text");
19+
setMedia(media);
20+
}
21+
};
22+
23+
/**
24+
*Ensures that the AnimationCard can be used as an attachment.
25+
*/
26+
@Test
27+
public void testToAttachment() {
28+
Attachment attachment = card.toAttachment();
29+
Assert.assertNotNull(attachment);
30+
Assert.assertEquals("application/vnd.microsoft.card.animation", attachment.getContentType());
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.microsoft.bot.schema;
5+
6+
import java.util.ArrayList;
7+
import org.junit.Assert;
8+
import org.junit.Test;
9+
10+
/***
11+
* Tests to ensure the AudioCard methods work as expected.
12+
*/
13+
public class AudioCardTest {
14+
ArrayList<MediaUrl> media = new ArrayList<MediaUrl>();
15+
16+
AudioCard card = new AudioCard(){
17+
{
18+
setText("Test Audio Text");
19+
setMedia(media);
20+
};
21+
};
22+
23+
/**
24+
*Ensures that the AudioCard can be used as an attachment.
25+
*/
26+
@Test
27+
public void testToAttachment() {
28+
Attachment attachment = card.toAttachment();
29+
Assert.assertNotNull(attachment);
30+
Assert.assertEquals("application/vnd.microsoft.card.audio", attachment.getContentType());
31+
}
32+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.microsoft.bot.schema;
5+
6+
import org.junit.Assert;
7+
import org.junit.Test;
8+
9+
/***
10+
* Tests to ensure the HeroCard methods work as expected.
11+
*/
12+
public class HeroCardTest {
13+
HeroCard card = new HeroCard(){
14+
{
15+
setTitle("Hero Card Title");
16+
setSubtitle("Hero Card Subtitle");
17+
setText("Testing Text.");
18+
}
19+
};
20+
21+
/**
22+
* Ensures that the HeroCard can be added as an attachment.
23+
*/
24+
@Test
25+
public void testToAttachment() {
26+
Attachment attachment = card.toAttachment();
27+
Assert.assertNotNull(attachment);
28+
Assert.assertEquals("application/vnd.microsoft.card.hero", attachment.getContentType());
29+
}
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.microsoft.bot.schema;
5+
6+
import org.junit.Assert;
7+
import org.junit.Test;
8+
9+
/***
10+
* Tests to ensure the OAuthCard methods work as expected.
11+
*/
12+
public class OAuthCardTest {
13+
OAuthCard card = new OAuthCard(){
14+
{
15+
setText("Test OAuth Text");
16+
setConnectionName("Test Connection Name");
17+
}
18+
};
19+
20+
/**
21+
*Ensures that the OAuthCard can be used as an attachment.
22+
*/
23+
@Test
24+
public void testToAttachment() {
25+
Attachment attachment = card.toAttachment();
26+
Assert.assertNotNull(attachment);
27+
Assert.assertEquals("application/vnd.microsoft.card.oauth", attachment.getContentType());
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.microsoft.bot.schema;
5+
6+
import org.junit.Assert;
7+
import org.junit.Test;
8+
9+
/***
10+
* Tests to ensure the AnimationCard methods work as expected.
11+
*/
12+
public class ReceiptCardTest {
13+
14+
ReceiptCard card = new ReceiptCard() {
15+
{
16+
setTitle("John Doe");
17+
}
18+
};
19+
20+
/**
21+
* Ensures that the ReceiptCard can be added as an attachment.
22+
*/
23+
@Test
24+
public void testToAttachment() {
25+
Attachment attachment = card.toAttachment();
26+
Assert.assertNotNull(attachment);
27+
Assert.assertEquals("application/vnd.microsoft.card.receipt", attachment.getContentType());
28+
}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.microsoft.bot.schema;
5+
6+
import org.junit.Assert;
7+
import org.junit.Test;
8+
9+
/***
10+
* Tests to ensure the SigninCard methods work as expected.
11+
*/
12+
public class SigninCardTest {
13+
SigninCard card = new SigninCard(){
14+
{
15+
setText("Test Signin Text");
16+
}
17+
};
18+
19+
/**
20+
*Ensures that the SigninCard can be used as an attachment.
21+
*/
22+
@Test
23+
public void testToAttachment() {
24+
Attachment attachment = card.toAttachment();
25+
Assert.assertNotNull(attachment);
26+
Assert.assertEquals("application/vnd.microsoft.card.signin", attachment.getContentType());
27+
}
28+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.microsoft.bot.schema;
5+
6+
import org.junit.Assert;
7+
import org.junit.Test;
8+
9+
/***
10+
* Tests to ensure the ThumbnailCard methods work as expected.
11+
*/
12+
public class ThumbnailCardTest {
13+
ThumbnailCard card = new ThumbnailCard(){
14+
{
15+
setText("Test Thumbnail Text");
16+
setTitle("Test Thumbnail Title");
17+
setSubtitle("Test Thumbnail Subtitle");
18+
setImage(new CardImage());
19+
setTap(new CardAction());
20+
}
21+
};
22+
23+
/**
24+
*Ensures that the ThumbnailCard can be used as an attachment.
25+
*/
26+
@Test
27+
public void testToAttachment() {
28+
Attachment attachment = card.toAttachment();
29+
Assert.assertNotNull(attachment);
30+
Assert.assertEquals("application/vnd.microsoft.card.thumbnail", attachment.getContentType());
31+
}
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.microsoft.bot.schema;
5+
6+
import org.junit.Assert;
7+
import org.junit.Test;
8+
9+
/***
10+
* Tests to ensure the VideoCard methods work as expected.
11+
*/
12+
public class VideoCardTest {
13+
VideoCard card = new VideoCard(){
14+
{
15+
setTitle("Test Video Title");
16+
setSubtitle("Test Video Subtitle");
17+
setText("Test Video Text");
18+
setImage(new ThumbnailUrl());
19+
}
20+
};
21+
22+
/**
23+
*Ensures that the VideoCard can be used as an attachment.
24+
*/
25+
@Test
26+
public void testToAttachment() {
27+
Attachment attachment = card.toAttachment();
28+
Assert.assertNotNull(attachment);
29+
Assert.assertEquals("application/vnd.microsoft.card.video", attachment.getContentType());
30+
}
31+
}

0 commit comments

Comments
 (0)