Skip to content

Instantly share code, notes, and snippets.

jose-mgmaestre

Block or report user

Report or block jose-mgmaestre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Body body = createBody();
View Doctor.java
@Component( modules = RandomInjectionModule.class )
public interface Doctor {
Body injectBlood();
}
@jose-mgmaestre
jose-mgmaestre / RandomInjectionModule.java
Last active Apr 16, 2018
This class will inject random blood objects for a Blood interface
View RandomInjectionModule.java
@Module
public class RandomInjectionModule {
private static Blood blood;
public RandomInjectionModule() {
}
@Provides
static Blood provideBlood(){
View A_Blood
public class A_Blood extends Blood{
@Override
public String getKindOfBlood() {
return "A";
}
}
View Blood.java
public abstract class Blood {
public abstract String getKindOfBlood();
}
View Body.java
public class Body {
@Inject
Blood blood;
@Inject
public Body(){}
View Person.java
public class Person{
Body body;
@Inject
public Person(Body body){
this.body = body;
}
}
@jose-mgmaestre
jose-mgmaestre / Body.java
Created Apr 13, 2018
Body as simple as possible to explain the injection
View Body.java
package com.ricston.injectionexample.domain;
import com.ricston.injectionexample.domain.com.ricston.injectionexample.domain.blood.Blood;
import javax.inject.Inject;
public class Body {
@Inject
public Body(){}
View MultitenantConnectionProviderTest.java
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:META-INF/spring/testContext.xml" })
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
public class MultiTenantConnectionProviderTest {
...
@Autowired
MultiTenantConnectionProviderImpl multitenancyConnectionProvider;
@jose-mgmaestre
jose-mgmaestre / CurrentTenantIdentifierResolverImpl.java
Last active Jan 17, 2018
Multitenancy junit test : Using a global tenant
View CurrentTenantIdentifierResolverImpl.java
/**
* It specify what Tenant should be used:
* <p>
* <p>
* There are 2 modes of resolving the identifier using {@link #resolveCurrentTenantIdentifier()}:
*
* <li> Using a global tenant identifier for junit testing
* <li> Using the http session to get the tenant for deployed applications
*
You can’t perform that action at this time.