package br.com.senior.erpxfnd.produto.factory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import br.com.senior.messaging.context.functional.MessageSupplier;
import br.com.senior.messaging.context.functional.MessengerSupplier;
import br.com.senior.messaging.context.functional.TenantSupplier;
import br.com.senior.messaging.context.functional.UserSupplier;
import br.com.senior.platform.blobservice.BlobServiceStub;
import br.com.senior.platform.blobservice.BlobServiceStubImpl;
import br.com.senior.sdl.user.BasicUserIdentifier;
import br.com.senior.utils.ProjectConstants;
import lombok.AccessLevel;
import lombok.Setter;
import lombok.experimental.FieldDefaults;
@Primary
@Component
@Setter(onMethod_ = @Autowired)
@FieldDefaults(level = AccessLevel.PRIVATE)
public class StubFactory {
MessengerSupplier messengerSupplier;
TenantSupplier tenantSupplier;
UserSupplier userSupplier;
MessageSupplier messageSupplier;
public BlobServiceStub getBlobServiceStub() {
return new BlobServiceStubImpl( //
() -> messengerSupplier.get(), //
new BasicUserIdentifier(userSupplier.get(), tenantSupplier.get(), /* trusted */false), //
() -> messageSupplier.get() //
);
}
public BlobServiceStub getBlobServiceTrustedStub() {
return new BlobServiceStubImpl( //
() -> messengerSupplier.get(), //
new BasicUserIdentifier(ProjectConstants.ADMIN_USER, tenantSupplier.get(), /* trusted */true), //
() -> messageSupplier.get() //
);
}
}