Last active
August 7, 2023 02:03
-
-
Save A-pZ/60fff9c4e97be6fc0b8930bc09a54844 to your computer and use it in GitHub Desktop.
取引先を新規登録するテストクラス
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
package com.github.apz.salesforcesample.repository | |
import com.github.apz.salesforcesample.model.Company | |
import org.springframework.beans.factory.annotation.Autowired | |
import org.springframework.boot.test.context.SpringBootTest | |
import spock.lang.Specification | |
@SpringBootTest | |
class SalesforceRegisterTest extends Specification { | |
@Autowired | |
SalesforceAuthentication authentication | |
@Autowired | |
CompanyRepository repository | |
def "登録"() { | |
when: | |
def company = new Company() | |
company.name = "テストコードから登録した会社" | |
company.recordTypeId = "0120o000001TahMAAS" // 取引先のレコードタイプを指定 | |
def authenticationResult = authentication.authentication() // Salesforceの認証を行い、、、 | |
def result = repository.register(company, authenticationResult) // 取引先を登録する | |
then: | |
noExceptionThrown() | |
result | |
result.success == true | |
result.errors.size() == 0 | |
} | |
def "登録エラー"() { | |
when: | |
def company = new Company() | |
company.name = "エラー登録の例" | |
// company.recordTypeId = "0120o000001TahMAAS" // 必須項目であるレコードタイプを設定しない例 | |
def authenticationResult = authentication.authentication() | |
def result = repository.register(company, authenticationResult) | |
then: | |
noExceptionThrown() | |
result | |
result.success == false // 登録失敗 | |
result.errors.size() != 0 // エラー情報が存在 | |
} | |
} |
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
INFO 18084 --- [ Test worker] c.g.a.s.repository.CompanyRepository : | |
result: RegisterResult( | |
id=0010l00001dKTpjAAG, | |
success=true, | |
errors=[] | |
) | |
INFO 18392 --- [ Test worker] c.g.a.s.repository.CompanyRepository : | |
result: RegisterResult( | |
id=null, | |
success=false, | |
errors=[{ | |
message=レコードタイプ ID: this ID value isn't valid for the user: , | |
errorCode=INVALID_CROSS_REFERENCE_KEY, | |
fields=[RecordTypeId] | |
}] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment