@Before
  public void setup() throws Exception {
    SlingSettingsService settings = mock(SlingSettingsService.class);
    slingId = UUID.randomUUID().toString();
    when(settings.getSlingId()).thenReturn(slingId);

    hello = new HelloWorldModel();
    PrivateAccessor.setField(hello, "settings", settings);
    hello.init();
  }
  @Test
  public void testHelloWorldModelServerSide() throws Exception {
    assertNotNull("Expecting HelloWorldModel to be injected by Sling test runner", hello);

    assertNotNull("Expecting the slingsettings to be injected by Sling test runner", settings);

    assertTrue(
        "Expecting the HelloWorldModel to return the slingId as part of the message",
        hello.getMessage().contains(settings.getSlingId()));
  }
  @Before
  public void setup() throws Exception {
    resource = context.create().resource("app/content/any/resource");
    context.addModelsForPackage("com.thoughtworks.www.samples.models");

    String slingId = UUID.randomUUID().toString();
    when(settings.getSlingId()).thenReturn(slingId);

    buttonModel = context.currentResource(resource).adaptTo(ButtonModel.class);
    PrivateAccessor.setField(buttonModel, "settings", settings);
  }
 /**
  * Return if it is in author mode.
  *
  * @return if it is in author mode.
  */
 private boolean isAuthorMode() {
   return settingsService != null && settingsService.getRunModes().contains("author");
 }
 @Override
 public String getMessage() {
   return "This is 0.0.5 snapshot " + settings.getSlingId();
 }
 @PostConstruct
 protected void init() {
   message = "\tHello World!\n";
   message += "\tThis is instance: " + settings.getSlingId() + "\n";
   message += "\tResource type is: " + resourceType + "\n";
 }
Beispiel #7
0
 private boolean isPublish() {
   return slingSettings.getRunModes().contains("publish");
 }