コード例 #1
0
  @Test
  public void shouldNotContinueWithConfigSaveIfRequestIsNotFresh() {
    when(goConfigService.isUserAdmin(currentUser)).thenReturn(true);
    when(goConfigService.isGroupAdministrator(currentUser.getUsername())).thenReturn(false);

    SCM updatedScm =
        new SCM(
            "id",
            new PluginConfiguration("plugin-id", "1"),
            new Configuration(
                new ConfigurationProperty(
                    new ConfigurationKey("key1"), new ConfigurationValue("value1"))));
    updatedScm.setName("material");
    when(entityHashingService.md5ForEntity(cruiseConfig.getSCMs().find("id"), "material"))
        .thenReturn("another-md5");
    UpdateSCMConfigCommand command =
        new UpdateSCMConfigCommand(
            updatedScm,
            pluggableScmService,
            goConfigService,
            currentUser,
            result,
            "md5",
            entityHashingService);

    assertThat(command.canContinue(cruiseConfig), is(false));
    assertThat(result.toString(), containsString("STALE_RESOURCE_CONFIG"));
    assertThat(result.toString(), containsString(updatedScm.getName()));
  }
コード例 #2
0
 @Override
 public CaseInsensitiveString getName() {
   if (nameIsEmpty() && !scmNameIsEmpty()) {
     return new CaseInsensitiveString(scmConfig.getName());
   } else {
     return name;
   }
 }
コード例 #3
0
 private boolean scmNameIsEmpty() {
   return (scmConfig == null || scmConfig.getName() == null || scmConfig.getName().isEmpty());
 }
コード例 #4
0
 @Override
 protected void appendAttributes(Map<String, Object> parameters) {
   parameters.put("scmName", scmConfig.getName());
 }