Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,35 @@ class SyncjobRestApiSpec extends Specification implements OkHttpRestTrait {
if(body && body.id) removeJob(body.id as Long)
}

void "ops not supported"() {
when:
def resp = post(endpoint, [sourceId:"123"])
def custBody = bodyToMap(resp)

then: "Verify cust tags created"
resp.code() == 403
custBody
custBody.detail.contains "Syncjob does not support operation 'create'"

when:
resp = put(endpoint + "/1", [sourceId:"123"])
custBody = bodyToMap(resp)

then: "Verify cust tags created"
resp.code() == 403
custBody
custBody.detail.contains "Syncjob does not support operation 'update'"

when:
resp = delete(endpoint + "/1")
custBody = bodyToMap(resp)

then: "Verify cust tags created"
resp.code() == 403
custBody
custBody.detail.contains "Syncjob does not support operation 'delete'"
}

@Transactional
SyncJob createMockJob() {
SyncJob job = new SyncJob([sourceType: SourceType.ERP, sourceId: 'ar/org'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import groovy.transform.CompileStatic
import org.springframework.stereotype.Component

import gorm.tools.job.JobUtils
import gorm.tools.job.SyncJobEntity
import gorm.tools.repository.model.DataOp
import yakworks.api.HttpStatus
import yakworks.api.problem.data.DataProblem
import yakworks.api.problem.data.DataProblemException
import yakworks.commons.map.Maps
import yakworks.gorm.api.DefaultCrudApi

Expand All @@ -25,6 +30,34 @@ class SyncJobCrudApi extends DefaultCrudApi<SyncJob> {
super(SyncJob)
}

CrudApiResult<SyncJob> create(Map data, Map params) {
throw notSupported("create")
}

CrudApiResult<SyncJob> update(Map data, Map params) {
throw notSupported("update")
}


CrudApiResult<SyncJob> upsert(Map data, Map params) {
throw notSupported("upsert")
}


void removeById(Serializable id, Map params) {
throw notSupported("delete")
}

@Override
SyncJobEntity bulk(DataOp dataOp, List<Map> dataList, Map qParams, String sourceId) {
throw notSupported("bulk")
}

private DataProblemException notSupported(String op) {
throw DataProblem.ex("Syncjob does not support operation '$op'").status(HttpStatus.FORBIDDEN.code)
}


@Override
Map entityToMap(SyncJob job, List<String> includes){
//clone metamap, SomeHow trying to put a new entry in MetaMap throws UnSupportedOperationException
Expand Down